Skip to content

Instantly share code, notes, and snippets.

@Karthik-B-06
Last active May 16, 2020 11:33
Show Gist options
  • Save Karthik-B-06/06dce09ff919c65a49f1ef5b8f29df69 to your computer and use it in GitHub Desktop.
Save Karthik-B-06/06dce09ff919c65a49f1ef5b8f29df69 to your computer and use it in GitHub Desktop.
A hook handling form data
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