Skip to content

Instantly share code, notes, and snippets.

@olitreadwell
Last active October 22, 2021 01:50
Show Gist options
  • Save olitreadwell/65605e30e6a3845ea7db03a10d68b92d to your computer and use it in GitHub Desktop.
Save olitreadwell/65605e30e6a3845ea7db03a10d68b92d to your computer and use it in GitHub Desktop.
js reactjs bind form or input elements with state
class CName extends Component {
constructor() {
this.state = {
firstname: "",
};
}
handleInputChange = (e) => {
this.setState({
firstname: e.target.value,
});
};
render() {
return (
<div>
<input type="text" value={this.state.firstname} onChange={this.handleInputChange} />
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment