LogoLogo
  • Home
  • Services
    • Fiber
    • Accessor
    • Schema
    • Form
    • Translator
  • Components
    • <Router/>
    • <Memo />
  • Observables
    • Async
    • Value
    • Store
    • List
    • Local Storage Value
    • Local Storage Store
    • Local Storage List
  • Hooks
    • useAsync
    • useAffect
    • useStream
    • useAction
    • useDebounce
    • useThrottle
    • usePrevious
    • useIdle
    • useValue
    • useList
    • useStore
    • useForm
    • useFormBinder
    • useTranslator
    • useQuery
  • Helpers
    • Tag
    • Input Helpers
    • Promise Helpers
    • Save Helpers
    • Pagination Helpers
    • Clipboard Helpers
    • Calendar Helpers
    • Local Storage Helpers
Powered by GitBook
On this page

Was this helpful?

  1. Hooks

useForm

React hooks for the @corets/form package.

PrevioususeStoreNextuseFormBinder

Last updated 2 years ago

Was this helpful?

Source code is hosted on

yarn add @corets/use-form
npm install --save @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)} />
    </>
  )
}
GitHub
Form