@veritem/useform
TypeScript icon, indicating that this package has built-in type declarations

0.0.15 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @veritem/useform

Weekly Downloads

1

Version

0.0.15

License

MIT

Unpacked Size

5.33 kB

Total Files

6

Last publish

Collaborators

  • veritem