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

0.0.5 • Public • Published

@glocurrency/use-form

A React hook to help manage form data


Install

$ pnpm add @glocurrency/use-form

Usage

import { useForm } from '@glocurrency/use-form'

const OrderForm() => {
  const { data, setData, post, errors, processing } = useForm({ amount: 100.00 })

  return (
    <>
      <TextField
        label="Amount"
        value={data.amount}
        value={data.amount?.toString()}
        onChange={(v) => setData('amount', Number(v))}
        error={errors.amount}
      />
      <Button
        variant="primary"
        onClick={() => post(`/orders/${orderId}`)}
        accessibilityLabel="Update"
        disabled={processing}
      >
        {processing ? 'Updating..' : 'Update'}
      </Button>
    </>
  )
}

Authors

Readme

Keywords

none

Package Sidebar

Install

npm i @glocurrency/use-form

Weekly Downloads

0

Version

0.0.5

License

MIT

Unpacked Size

14.4 kB

Total Files

17

Last publish

Collaborators

  • ivan-glocurrency
  • brokeyourbike