Skip to content

Instantly share code, notes, and snippets.

@enkot
Last active July 26, 2017 07:14
Show Gist options
  • Save enkot/b9a50efbd2a7af27aa9506c56112d0a0 to your computer and use it in GitHub Desktop.
Save enkot/b9a50efbd2a7af27aa9506c56112d0a0 to your computer and use it in GitHub Desktop.
import React from 'react';
import ReactDOM from 'react-dom';
class Welcome extends React.Component {
constructor(props) {
super(props);
this.handleChange = this.handleChange.bind(this);
this.state = {name: 'Medium'};
}
handleChange(e) {
this.setState({name: e.target.value});
}
render() {
return (
<div style={{textAlign: 'center'}}>
<h1>Welcome</h1>
<p>Hello {this.state.name}</p>
<input onChange={this.handleChange} defaultValue={this.state.name}/>
</div>
);
}
}
ReactDOM.render(<Welcome/>, document.getElementById('app'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment