February 08, 2017

react passing props to this.props.children

Previous article I mentioned about this.props.children and its feature, problem is this.props.children does not not provide a way to pass down the props, so we need a wrapper called React.cloneElement which allows you get this component and return a new component where you can also pass in the props like this:

by the way there are more very useful helpers to help you interacting with this.props.children, for example:

see all API at React.children