Skip to content

Instantly share code, notes, and snippets.

@blizzerand
Created November 28, 2018 09:39
Show Gist options
  • Save blizzerand/9ab1e7a2d08d23019f70fc2bde9ba6cf to your computer and use it in GitHub Desktop.
Save blizzerand/9ab1e7a2d08d23019f70fc2bde9ba6cf to your computer and use it in GitHub Desktop.
React forms - storylens
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