Created
February 11, 2016 17:12
-
-
Save ryanflorence/4e79ea80073db4051c9a 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
import serializeForm from 'form-serialize' | |
const Something = React.createClass({ | |
getInitialState() { | |
return { | |
form: {} | |
} | |
}, | |
syncFormToState(event) { | |
this.setState({ | |
form: serializeForm(event.target, { hash: true }) | |
}) | |
}, | |
render() { | |
return ( | |
<form onChange={this.syncFormToState}> | |
<input name="one"/> | |
<input name="two"/> | |
<input name="three[four]"/> | |
<input name="three[five]"/> | |
</form> | |
) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment