@nialldbarber/react-use-form

A real simple hook for using forms in react

NPM JavaScript Style Guide

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