Rabu, 13 Maret 2019

React.Children with non-element children

Given a component receives a function as a child (callback as a child pattern, also known as render prop pattern):


<Foo>{() => <Bar/>}</Foo>

React.Children.count(props.children) === 0 in Foo.

The documentation doesn't seem to mention that React.Children accepts only valid React elements, so the fact that child function is ignored looks odd.

How does React.Children treat non-element children and why?

References to official sources and/or source code are welcome.



from React.Children with non-element children

React.Children with non-element children Rating: 4.5 Diposkan Oleh: Admin

0 komentar:

Posting Komentar

Popular Posts