Skip to content

Instantly share code, notes, and snippets.

@pnispel
Created February 8, 2018 19:34
Show Gist options
  • Save pnispel/d25c95445d79e05d63ef88157ea08dea to your computer and use it in GitHub Desktop.
Save pnispel/d25c95445d79e05d63ef88157ea08dea to your computer and use it in GitHub Desktop.
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>
)
}
}
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