Skip to content
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

Boolean props with a default value of true are not rendered when the value is false #67

Closed
beauroberts opened this issue Dec 7, 2016 · 2 comments

Comments

@beauroberts
Copy link
Collaborator

beauroberts commented Dec 7, 2016

If you create a component with a default boolean prop set to true, like this:

class DefaultPropsComponent extends React.Component {}

DefaultPropsComponent.defaultProps = {test: 'test', something: true};

and then render an instance of that component where the prop is false:

reactElementToJSXString(<DefaultPropsComponent something={false} />, {showDefaultProps: false})
// Result: <DefaultPropsComponent />

the resulting string does not include something={false} as expected.

I'll submit a PR momentarily!

beauroberts added a commit to beauroberts/react-element-to-jsx-string that referenced this issue Dec 7, 2016
Fix an issue where boolean props with a default value of `true` are not
rendered when their value is `false`
@vvo vvo closed this as completed in #68 Dec 8, 2016
vvo pushed a commit that referenced this issue Dec 8, 2016
Fix an issue where boolean props with a default value of `true` are not
rendered when their value is `false`
@pascalduez
Copy link
Contributor

I just updated to 5.0.4 but still can't get a foobar={false} to render.

I will try to narrow down to a bare repo example.

@vvo
Copy link
Contributor

vvo commented Dec 14, 2016

Ok that would be great, maybe it did not build properly? Check what's inside node_modules and let us know, feedback counts!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants