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

Fix bug where string would cause invariant error. #51

Merged
merged 1 commit into from
Apr 24, 2016

Conversation

eightypop
Copy link
Contributor

This PR fixes a bug that the switch to React.Children exposed.

Children were always either being wrapped or cloned due to the fact that the props object existed even when there were no keys. Before using React.Children to check length for wrapping, we were using props.children.length which when it was a string, it's length property would force it to be wrapped. UsingReact.Children.count no longer allowed this to happen and since the props object was truthy, it would try to clone the text node which caused an invariant error.

The first fix is to check the length the keys array for the props object instead of the truthiness of the props object itself. This allows text nodes to be rendered unless there are props to merge which would still cause an error. In this case we want to wrap the text node so any lingering props can be passed to the wrapping component.

Modified the sample to expose this.

@eightypop eightypop mentioned this pull request Apr 22, 2016
@eightypop
Copy link
Contributor Author

#52 tests for this case and the current build fails it.

@yocontra yocontra merged commit d859537 into yocontra:master Apr 24, 2016
@eightypop eightypop deleted the string-fix branch October 19, 2016 15:28
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

Successfully merging this pull request may close these issues.

2 participants