Skip to content

Conversation

@gpittarelli
Copy link
Contributor

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
@gajus
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 📦🚀

@gajus gajus added the released label Mar 29, 2019
@gpittarelli
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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants