@nialldbarber/react-use-form
v1.0.3
Published
A hook for using forms in react
Downloads
3
Maintainers
Readme
@nialldbarber/react-use-form
A real simple hook for using forms in react
Install
npm install --save @nialldbarber/react-use-form
Usage
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>
);
};
License
MIT © nialldbarber