@mozisan/react-form
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

@mozisan/react-form

Installation

$ npm install -S @mozisan/react-form
$ yarn add @mozisan/react-form

Basic usage

import {
  boolean,
  number,
  string,
  useForm,
} from '@mozisan/react-form';
import React from 'react';

export const RegistrationForm: React.FC = () => {
  const { field, handleSubmit } = useForm({
    fields: {
      name: string(),
      age: number(),
      acceptsPolicy: boolean(),
    },
  });

  return (
    <form onSubmit={handleSubmit((data) => { ... })}>
      <div>
        <input ref={field('name')} type="text" />
      </div>

      <div>
        <input ref={field('age')} type="number" />
      </div>

      <div>
        <input ref={field('acceptsPolicy')} type="checkbox" />
      </div>

      <button type="submit">Submit</button>
    </form>
  );
};

Dependencies (1)

Dev Dependencies (24)

Package Sidebar

Install

npm i @mozisan/react-form

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

93.1 kB

Total Files

187

Last publish

Collaborators

  • mozisan