class Parent extends React.Component {
foo() {
console.log('i was called');
}
render() {
return(
this.props.childen;
);
}
}
class Child extends React.Component {
render() {
return(
<div onClick="call foo here">Child</div>
);
}
}
React.render(<Parent><Child></Parent>, document.getElementById('View'));
Im trying to render out Child like its shown in the last line. In this scenario, how can I pass foo()
from Parent to Child?
I know normally in Parent's render we do <Child func={this.foo} />