Created
July 1, 2016 17:32
-
-
Save jquense/867760097250515ce78325f515936baf to your computer and use it in GitHub Desktop.
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
class Form extends React.Component { | |
constructor() { | |
super() | |
this.state = { | |
name: null | |
} | |
} | |
componentWillReceiveProps(nextProps) { | |
if (nextProps.initialData && !this.props.initialData) { | |
this.setState(this.nextProps.initialData) | |
} | |
} | |
render() { | |
return ( | |
<div> | |
<input | |
onChange={e => this.setState({ name: e.target.value })} | |
value={this.state.name} | |
/> | |
</div> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment