Skip to content

Instantly share code, notes, and snippets.

@markodayan
Created March 5, 2020 21:33
Show Gist options
  • Save markodayan/a6c34ab0b06d4b4d64297c3ec614d9f1 to your computer and use it in GitHub Desktop.
Save markodayan/a6c34ab0b06d4b4d64297c3ec614d9f1 to your computer and use it in GitHub Desktop.
Custom Hooks in React (Form Input State Management)
import { useState } from 'react';
export const useForm = initialValues => {
const values, setValues[ = useState(initialValues);
return [
values,
e => {
setValues({
...values,
[e.target.name]: e.target.value
});
}
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment