Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MorenoMdz/b231ecd6443665660b158b3adbcca3e1 to your computer and use it in GitHub Desktop.
Save MorenoMdz/b231ecd6443665660b158b3adbcca3e1 to your computer and use it in GitHub Desktop.
/* Controlled Component With Update */
<input
type='text'
name='inputText'
value={this.state.inputText}
onChange={(e) => {
this.setState({inputText: e.target.value})
}}
/>
/**
* On every change event (e) (letter type etc) it will call this.state.inputText
* with the value from e.target.value
* That will call render and update the value in the component.
* The next time something is input setState will call the render and run it again
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment