reactjs
Bind form or input elements with state in React
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>
);
}
}
Was this helpful?
Similar Posts