Forked from TCotton/react-change-state-view-dyn.js
Created
February 23, 2017 08:28
-
-
Save TatuPutto/300ea17814257024da4ce6ad174d7e01 to your computer and use it in GitHub Desktop.
React change state view dynamically
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
| 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