Skip to content

Instantly share code, notes, and snippets.

@JerryLeeCS
Created August 11, 2018 19:50
Show Gist options
  • Save JerryLeeCS/9a812f4810af3a1f18caa58fc7260a6e to your computer and use it in GitHub Desktop.
Save JerryLeeCS/9a812f4810af3a1f18caa58fc7260a6e to your computer and use it in GitHub Desktop.
ReactJS binding state to to input value
onChange(e) {
this.setState({ [e.target.name]: e.target.value });
}
<input
type="password"
placeholder="Password"
name="password"
value={this.state.password}
onChange={this.onChange}
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment