Last active
May 16, 2020 11:33
-
-
Save Karthik-B-06/06dce09ff919c65a49f1ef5b8f29df69 to your computer and use it in GitHub Desktop.
A hook handling form data
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
| import { useState } from "react"; | |
| export const formData = (values) => { | |
| const [formValues, setFormValues] = useState({ | |
| ...values | |
| }); | |
| const handleFormValueChange = (key, value) => { | |
| setFormValues( | |
| { | |
| ...formValues, | |
| [key]: value | |
| } | |
| ); | |
| }; | |
| return [ | |
| formValues, | |
| handleFormValueChange, | |
| setFormValues, | |
| ] | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment