Children
Grid.js
function Grid(props) {
return <div>{props.children}</div>;
}Usage
<Grid>
<Row />
<Row />
<Row />
</Grid>Extra
Children can be anything, any type so use helpers
<Fetch url="api.myself.com">
{(result) => <p>{result}</p>}
</Fetch>To Change Children
renderChildren() {
return React.Children.map(this.props.children, child => {
return React.cloneElement(child, {
name: this.props.name
})
})
}Helpers
React.Children.map
Better than this.props.children.map b/c if ft would map would be undefined
React.Children.count
If you just passed a raw string, would count length of string oops
React.Children.toArray
Last updated