Skip to content

Instantly share code, notes, and snippets.

@daniilgrigoryev
Created August 1, 2019 08:59
Show Gist options
  • Select an option

  • Save daniilgrigoryev/e56b71a5b8f146ce3e019f01793971c1 to your computer and use it in GitHub Desktop.

Select an option

Save daniilgrigoryev/e56b71a5b8f146ce3e019f01793971c1 to your computer and use it in GitHub Desktop.
дочерний в родительский
// родительский
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