I'm trying to pass extra props to this.props.children, I saw this answer how to pass props to children with React.cloneElement?
and from some reason although I'm not getting any error I can't see the prop
So I have this state
this.state = {
open: true
}
and I want to pass it down to this.props.children, and this is what I've done so far:
{
React.Children.map(this.props.children, child =>
React.cloneElement(child, {sidebarState: this.state.open}))
}
and when I'm console.logging this.props on the children I can't see my new props.
--- EDIT --- In the children it looks like this:
render() {
console.log(this.props)
// other code
}
BTW I'm using react 16.0