Created
February 8, 2018 19:34
-
-
Save pnispel/d25c95445d79e05d63ef88157ea08dea to your computer and use it in GitHub Desktop.
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 Child extends Component { | |
onChange() { | |
this.props.onUpdate(this.inputEl.val) | |
} | |
render() { | |
return ( | |
<div> | |
<input onChange={this.onChange} value={this.props.someFoo} ref={(el) => this.inputEl = el} /> | |
</div> | |
) | |
} | |
} |
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 Container extends Component { | |
state = { | |
someFoo: 1 | |
} | |
onUpdate(newFoo) { | |
this.setState({someFoo: newFoo}) | |
} | |
render() { | |
return ( | |
<Child onUpdate={this.onUpdate} someFoo={this.state.someFoo} /> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment