Created
November 28, 2018 09:39
-
-
Save blizzerand/9ab1e7a2d08d23019f70fc2bde9ba6cf to your computer and use it in GitHub Desktop.
React forms - storylens
This file contains 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
import React from 'react'; | |
class App extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
data: 'Default data' | |
} | |
this.updateState = this.updateState.bind(this); | |
}; | |
updateState(e) { | |
this.setState({data: e.target.value}); | |
} | |
render() { | |
return ( | |
<div> | |
<input type = "text" value = {this.state.data} | |
onChange = {this.updateState} /> | |
<h4>{this.state.data}</h4> | |
</div> | |
); | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment