This function create the entire form state subscription and allow you to subscribe update with or without react component.
Props
This following table applied to FormProvider
, useFormContext
accepts no argument.
Name | Type | Description |
---|---|---|
...props | Object | UseFormProps |
NOTES
- This function is published at v7.55.0-next.1 - This function is
completely optional, you can consider to use this instead of
useFormContext
API. - You may find it useful if you would like to subscribe formsState by skipping react re-render.
Examples:
const { formControl, control } = createFormControl({mode: 'onChange',defaultValues: {firstName: 'Bill'}}})function App() {const { register, handleSubmit } = useForm({formControl,})return (<form onSubmit={handleSubmit(data => console.log)}><input {...register('name')} /><FormState /><Controller /></form>);}function FormState() {useFormState({control // no longer need context api})}function Controller() {useFormState({control // no longer need context api})}
Thank you for your support
If you find React Hook Form to be useful in your project, please consider to star and support it.