Update index.js for possible crash with RN 0.59.9 #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.