/useform

Tiny hook that make react forms easy

Primary LanguageTypeScriptMIT LicenseMIT

useForm

npm

Tiny hook to use form state in your component.

Usage

import useForm from '@veritem/useform';

export default function App() {
  const { handleChange, inputs, clearForm } = useForm({
    name: '',
    email: '',
    password: '',
  });

  function handleSubmit(e) {
    e.preventDefault();
    console.log(inputs);
  }

  return (
    <section>
      <form onSubmit={handleSubmit}>
        <input
          type="text"
          name="name"
          value={inputs.name}
          onChange={handleChange}
        />
        <input
          type="text"
          name="email"
          value={inputs.email}
          onChange={handleChange}
        />
        <input
          type="text"
          name="password"
          value={inputs.password}
          onChange={handleChange}
        />
        <button type="submit">Submit</button>
      </form>
    </section>
  );
}

License

MIT Licence © 2022 - present veritem