Created
March 20, 2017 16:22
-
-
Save john1jan/507e3c3a84913c3eff80236e8ede13c8 to your computer and use it in GitHub Desktop.
Child Contructor Binding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ChildComponent extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { message: 'I am Child ' }; | |
this.printChild = this.printChild.bind(this); | |
} | |
render() { | |
return <div> | |
<p> Child Component</p> | |
<input type="button" value="Print From Child" onClick={this.printChild} /> | |
</div> | |
} | |
printChild() { | |
console.log(this.state.message) | |
this.props.printParent( "Mars") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment