Last active
February 28, 2019 01:44
-
-
Save dewey92/0d8345be88a8898a4c71165112bcdcbc to your computer and use it in GitHub Desktop.
Partial App - Events
This file contains hidden or 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
| const FORM_ID = 'personal-details' | |
| // Factory | |
| const onChange = (fieldName: string) => e => { | |
| notifyParentOnFieldChange(FORM_ID, fieldName) | |
| // actual computaion | |
| const value = e.target.value | |
| ... | |
| } | |
| const Form = () => ( | |
| <form id={FORM_ID}> | |
| <input name="name" onChange={onChange('name')} /> | |
| <input name="address" onChange={onChange('address')} /> | |
| <input name="phoneNum" onChange={onChange('phoneNum')} /> | |
| ... | |
| </form> | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment