Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save TatuPutto/300ea17814257024da4ce6ad174d7e01 to your computer and use it in GitHub Desktop.

Select an option

Save TatuPutto/300ea17814257024da4ce6ad174d7e01 to your computer and use it in GitHub Desktop.
React change state view dynamically
export default class SetValueExample extends React.Component {
constructor() {
super();
this.state = {
myName: '',
};
}
setValue(e) {
this.setState({[e.target.name]: e.target.value});
}
render(){
return(
<input value={this.state.myName} name="myName" onChange={this.setValue} />
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment