Mapping Over One Or Many Children
Last updated
Was this helpful?
Last updated
Was this helpful?
In , I talked about how a child element can be reconstituted with additional props. The approach I showed will only work in the case of a single child being nested in that component. What if you want your component to account for one, many, or even children?
React comes with a built-in function for mapping that handles these cases.
The allows mapping over one or many elements and if children
is null
or undefined
, it will return null
or undefined
respectively.
See a .