Skip to content

Instantly share code, notes, and snippets.

@gladchinda
Created June 6, 2018 21:53
Show Gist options
  • Select an option

  • Save gladchinda/a31c40da54c8880e2fb115e3ac4ceeaf to your computer and use it in GitHub Desktop.

Select an option

Save gladchinda/a31c40da54c8880e2fb115e3ac4ceeaf to your computer and use it in GitHub Desktop.
class ControlledFormInput extends React.Component {
constructor(props) {
super(props);
this.handleChange = this.handleChange.bind(this);
this.state = { value: "Glad" };
}
handleChange(evt) {
this.setState({ value: evt.target.value });
}
render() {
return (
<div>
<h1>Hello {this.state.value}!</h1>
<input type="text" value={this.state.value} onChange={this.handleChange} placeholder="Enter your name" />
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment