Skip to content

Instantly share code, notes, and snippets.

@hai5nguy
Created November 4, 2016 15:32
Show Gist options
  • Save hai5nguy/b39564e97f458e1d2489a20901f38421 to your computer and use it in GitHub Desktop.
Save hai5nguy/b39564e97f458e1d2489a20901f38421 to your computer and use it in GitHub Desktop.
//parent.js
export default class Parent extends React.Component {
childClicked = (data) => {
console.log('data from child:', data)
}
render() {
return <Child onClick={this.childClicked} } />
}
}
//child.js
export default class Child extends React.Component {
clicked = (e) => {
var data = 'some data'
this.props.handleClick(data)
}
render() {
return <div onClick={this.prop.handleClick}>I am child</div>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment