score:3

Accepted answer
const useForm = (initialValues) => {
  const [values, setValues] = useState(initialValues);

  return [
    values,
    (e) => {
      setValues(prevValues => {
        return {
          ...prevValues,
          [e.target.name]: e.target.value,
        }
      });
    }
  ];
};

Related Query

More Query from same tag