-
-
Save pvlv/a8e50b4c8e9105d2121ec0f3230967fe to your computer and use it in GitHub Desktop.
A way to collect form data without `FormData` api.
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
| // https://medium.com/@everdimension/how-to-handle-forms-with-just-react-ac066c48bd4f | |
| handleSubmit(event) { | |
| const form = event.target; | |
| const data = {} | |
| for (let element of form.elements) { | |
| if (element.tagName === 'BUTTON') { continue; } | |
| data[element.name] = element.value; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment