Skip to content

Conversation

neoswallow
Copy link
Contributor

With RN 0.59.9 which includes new JavaScriptCore and if children was attached with {condition && Component} format and condition is false in non other than null/undefined (false || 0 || ‘’), (false || 0 || ‘’) is returned as children. Since children is (false || 0 || ‘’), it will pick Image component but when it’s returned, props.children is not null/undefined so it will crash as Image component will see it as having children. Checking it against null will make sure that ImageBackground is chosen to prevent crash. Existing module users can prevent crash by making sure null is returned by {condition && Component || null}. Another solution would be to override children if it’s (false || 0 || ‘’) but I figure sometimes less code is better.

With RN 0.59.9 which includes new JavaScriptCore and if children was attached with {condition && Component} format and condition is false in non other than null/undefined (false || 0 || ‘’), (false || 0 || ‘’) is returned as children. Since children is (false || 0 || ‘’), it will pick Image component but when it’s returned, props.children is not null/undefined so it will crash as Image component will see it as having children. Checking it against null will make sure that ImageBackground is chosen to prevent crash. Existing module users can prevent crash by making sure null is returned by {condition && Component || null}. Another solution would be to override children if it’s (false || 0 || ‘’) but I figure sometimes less code is better.
@wonday wonday merged commit a7b7cee into wonday:master Jul 13, 2019
@wonday
Copy link
Owner

wonday commented Jul 13, 2019

Thanks

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