-
Notifications
You must be signed in to change notification settings - Fork 81
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
useBooleanShorthandSyntax
strip false values
#732
Comments
Hi @pascalduez thanks for reporting this case. I see your point, the actual behavior came from the class component: we could set a default value on the for the props. We use there default value to know if the falsy boolean props should be shown. In that case it works as expected. Here the class component we use to test this behavior: react-element-to-jsx-string/src/index.spec.js Lines 22 to 29 in c9b7269
And the actual test: react-element-to-jsx-string/src/index.spec.js Lines 855 to 861 in c9b7269
That being said, in the actual react word we could said that most of the components are functional one. We could try to change this behavior to show |
Hey @armandabric, thanks for your reply.
|
I created a patch from @armandabric PR and it works. |
The
useBooleanShorthandSyntax
option (which is on by default), stripsfalse
values.While the behavior is fine for a
true
value:<Foo bar={true}>
--><Foo bar>
,it's not for a
false
value:<Foo bar={false}>
--><Foo>
,which is definitely not the same thing, the prop is removed completely.
The text was updated successfully, but these errors were encountered: