Function: FormProvider
▸ Const FormProvider<VS, SD, ES, WS>(props, ref): Element
This React component initializes and provides a FormState instance through the React context.
You can access the inner FormState instance with the useForm hook:
const Child = () => { const form = useForm();}const Example () => { return ( <FormProvider> <Child/> </FormProvider> );}by using a ref:
const Example () => { const formRef = useRef();
return ( <FormProvider ref={formRef}> ... </FormProvider> );}or by providing a render callback function as component children:
const Example () => { return ( <FormProvider> {(form) => { ... }} </FormProvider> );}Type parameters#
| Name | Type | Description |
|---|---|---|
VS | VS | Type of form value state. |
SD | unknown | Type of submit handler result. |
ES | undefined | Type of form error state. |
WS | undefined | Type of form warning state. |
Parameters#
| Name | Type |
|---|---|
props | FormProviderProps<VS, SD, ES, WS> |
ref | Ref<FormState<VS, SD, ES, WS>> |
Returns#
Element