@glocurrency/use-form
v0.0.5
Published
A React hook to help manage form data
Downloads
11
Readme
@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
- Ivan Stasiuk | Twitter | LinkedIn | stasi.uk