useCheckboxField()
This hook subscribes to the part of the form specified in name and returns props for checkbox field, meta information, and helpers.
Import
import { useCheckboxField } from 'exeform';Types
The returned value is almost identical to Field. The only difference is that the checked field is present instead of value.
useCheckboxField
useCheckboxFielduseCheckboxField(name: string): CheckboxFieldfield.checked
field.checkedbooleanExample
For nested values, use name as described here.
const Checkbox = ({ name, ...rest }) => {
const { field, meta, helpers } = useCheckboxField(name);
const error = meta.touched ? meta.error : null;
return (
<div>
<input {...field} {...rest} type="checkbox" />
{error ? <div>{error}</div> : null}
</div>
);
};
<Checkbox name="activated" />Last updated
Was this helpful?