Skip to main content

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#

NameTypeDescription
VSVSType of form value state.
SDunknownType of submit handler result.
ESundefinedType of form error state.
WSundefinedType of form warning state.

Parameters#

NameType
propsFormProviderProps<VS, SD, ES, WS>
refRef<FormState<VS, SD, ES, WS>>

Returns#

Element