I try to pass argument from child component to parent. P.S. Snippet below doesn't work if somebody fix this, it would be really great.
class Parent extends React.Component {
suggestionClick(id) {
console.log(this.props, id); // {props Object} , undefined
}
render(){
return (
<ChildComponent click={this.suggestionClick.bind(this)} />
);
}
}
const ChildComponent = ({ click }) => (
<SubChildComponent id="1" click={() => click()} />
);
const SubChildComponent = ({ click, id }) => (
<div className="subsubcomponent" click={() => click(id)} />
);
ReactDOM.render(
<Parent />,
document.getElementById('app')
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="app"></div>