A real simple hook for using forms in react
npm install --save @nialldbarber/react-use-form
import React from "react";
import { useForm } from "@nialldbarber/react-use-form";
const FormExample = () => {
const { values, handleChange, handleSubmit } = useForm({
foo: "foo",
bar: "bar",
baz: "baz"
});
return (
<form onSubmit={handleSubmit}>
<input
type="text"
value={values.foo}
name="foo"
onChange={handleChange}
/>
<input
type="text"
value={values.bar}
name="bar"
onChange={handleChange}
/>
<input
type="text"
value={values.baz}
name="baz"
onChange={handleChange}
/>
</form>
);
};
MIT © nialldbarber