Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: Don't break when spreading falsy value #249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
gajus merged 1 commit into gajus:master from Massdrop:gjp/handle-falsy-spread
Mar 29, 2019

Conversation

Copy link
Contributor

@gpittarelli gpittarelli commented Mar 29, 2019

The following is valid React:

const props = null;
<div {...props} styleName='a' />;

On master, after #243, this compiles to:

const props = null;
<div {...props} className={"foo__a" + (" " + (props.className || ""))} />;

However, this fails because it is trying to read the className property of null.

This PR fixes this (and updates the tests) by also compiling in a falsy-check around props:

const props = null;
<div {...props} className={"foo__a" + (" " + (props ? props.className || "" : ""))} />;

@gajus gajus merged commit f11d423 into gajus:master Mar 29, 2019
Copy link
Owner

gajus commented Mar 29, 2019

🎉 This PR is included in version 5.2.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Contributor Author

Thanks!

@gpittarelli gpittarelli deleted the gjp/handle-falsy-spread branch March 29, 2019 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /