Fix Switch component not matching/rendering nested array children correctly #1441
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.
Objective
This PR introduces a change to the way a Switch handles its child components, allowing for (nested) array children to sit next to regular component children.
A rough example of this would be the following:
Before this fix, this construct would result in a
TypeError: Cannot read property 'path' of undefined
.See the added tests in
Switch.spec.jsx
for more examples.When moving the child handling into a separate function, I have left the naming intact from the existing implementation, as this is my first attempt at contributing to this awesome project and I didn't want to rummage around too much. I'm always happy about feedback!