useForm

React hooks for the @corets/form package.

Source code is hosted on GitHub

yarn add @corets/use-form

This is a React integration for this package:

useForm()

Use forms inside React components:

import React from "react"
import { createForm } from "@corets/form"
import { useForm } from "@corets/use-form"

const Example = () => {
  const form = useForm(() => createForm({ text: "foo" }))
  
  return (
    <>
      <input 
        value={form.get("text")} 
        onChange={(e) => form.set("text", e.target.value)} />

      // with the static field
      
      <input 
        value={form.getFields().text.get().getValue()} 
        onChange={(e) => form.getFields().text.get().setValue(e.target.value)} />
    </>
  )
}

Last updated