Created
August 1, 2019 08:59
-
-
Save daniilgrigoryev/e56b71a5b8f146ce3e019f01793971c1 to your computer and use it in GitHub Desktop.
дочерний в родительский
This file contains hidden or 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
| // родительский | |
| render() { | |
| const myCallback = (dataFromChild) => this.dataFromChild = dataFromChild; | |
| } | |
| <SearchRoot callbackFromParent={this.myCallback}/> | |
| // дочерний | |
| class SearchRoot extends React.Component { | |
| constructor(props){ | |
| super(props); | |
| this.add = this.add.bind(this); | |
| } | |
| add(fieldLabel){ | |
| this.props.callbackFromParent(1); | |
| } | |
| return ( | |
| <select onChange={(evt)=>add(evt.target.value)}>{ADD}</select> | |
| ); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment