Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ThomasMeier/fc3d78f1f0b422e918f739b640fcbeaf to your computer and use it in GitHub Desktop.
Save ThomasMeier/fc3d78f1f0b422e918f739b640fcbeaf to your computer and use it in GitHub Desktop.
Wish
// state for entire app set up here
const state = {
user: {first: '', last: '', age: '', address: '', state: ''}
otherstuff: []
}
// a component somewhere
const myComponent = () => {
return (
<div>
// short one-liner updates application state with all form values
<form onSubmit={(e) => {merge('state.user', e.all.values)}}>
<input name="first" />
<input name="last" />
<input name="age" />
<input name="address" />
<input name="state" />
<input type="submit" />
</form>
</div>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment