Last active
October 22, 2021 01:50
-
-
Save olitreadwell/65605e30e6a3845ea7db03a10d68b92d to your computer and use it in GitHub Desktop.
js reactjs bind form or input elements with state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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