Closed
Description
My use case: wrapping all non-empty children into divs.
render() {
return (
<div style={rootStyle} onWheel={this.handleWheel}>
{Children.map(this.props.children, this.wrapChild)}
</div>
);
},
wrapChild(child, index) {
if (!child) { // I know this is probably wrong kind of comparison; don't care
return (
<div style={this.getChildStyle(index)}>
{child}
</div>
);
}
},
This is all nice but I also need to know how many valid children I have wrapped.
Children.count
will return the number of children including the “empty” children. I want to strip them out.
Can we have Children.filter
?