I have a generic component which maps its child components to filter only children of a certain type, as found below.
However, using the property type
w
I think your example is correct.
Indeed, in React 0.12 child.type === Foo.type
is the only comparison that works.
This is related to React 0.12 being in process of deprecating wrapper functions.
When 0.13 is out, child.type
itself will be Foo
.
Nitpick: don't use this.props.children.map
, this won't work when there is less than two children.
Use React.Children.map instead.