Skip to content

Instantly share code, notes, and snippets.

@loganpowell
Created January 17, 2018 15:44
Show Gist options
  • Save loganpowell/cbaca04a07a83d122b20aef234dbab01 to your computer and use it in GitHub Desktop.
Save loganpowell/cbaca04a07a83d122b20aef234dbab01 to your computer and use it in GitHub Desktop.
State Hoisting in React (Child to Parent communication)
//from: https://reactpatterns.com/#event-switch
class NameContainer extends React.Component {
constructor() {
super()
this.state = {name: ""}
}
render() {
return <Name onChange={newName => this.setState({name: newName})} />
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment