npm

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

0.1.4-alpha.0 • Public • Published

@faumally/react

React hooks for form handling backed by state machines

Usage

import useFaumally from "@faumally/react";

type Form = {
  age: number;
  email: string;
  address: string;
  lastName: string;
  firstName: string;
};

const config = { required: true };

const createUser = (user: any) => Promise.resolve();

const { submit, handlers, subscribe } = useFaumally<Form>({
  schema: {
    email: config,
    lastName: config,
    firstName: config,
    address: "string",
    age: {
      ...config,
      initialValue: 0,
    },
  },
  onSubmit(data) {
    return createUser(data);
  },
});

Package Sidebar

Install

npm i @faumally/react

Weekly Downloads

1

Version

0.1.4-alpha.0

License

MIT

Unpacked Size

38.3 kB

Total Files

13

Last publish

Collaborators

  • joshuaamaju