Created
July 23, 2020 04:28
-
-
Save ThomasMeier/fc3d78f1f0b422e918f739b640fcbeaf to your computer and use it in GitHub Desktop.
Wish
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
// 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