Reputation: 6368
this sounds like a bad question, but since children
is already an array
, while not call .map
directly? is it just for catching case where children is singular?
Upvotes: 0
Views: 50
Reputation: 394
Because children is not an array, is an opaque data structure, so that actually returns an array based on this.props.children
Here's the reference from the docs for more information.
https://reactjs.org/docs/react-api.html#reactchildren
Edit:
In the case of your edit is acts as an array because it includes several children, but it could also act as other data types depending on the number of children or if it has children at all, just like Charlie Martin pointed in his comment.
Upvotes: 1