Skip to main content

Form

Functions​

Form​

▸ Form<Values>(props): Element

A Form is reponsible for wrapping the Fields that you want to render. It will keep track of the form state and act as a context/provider for various hooks used within the Form's component tree.

Example Usage:

function UserProfile() {
return (
<Form name="UserProfile" initialValues={{ firstName: "" }}>
<TextField name="firstName" required pattern={/\w+/} as={({ input }) => <input {...input} />} />
</Form>
);
}

Type parameters​

NameTypeDescription
Valuesextends FormzValuesFormzValues - The shape of the forms state i.e. the form data.

Parameters​

NameTypeDescription
propsWebFormProps<Values>FormProps - The react props for the form component.

Returns​

Element

Defined in​

packages/react-formz-web/src/components/Form/Form.tsx:54


PersistedForm​

▸ PersistedForm<Values>(__namedParameters): Element

A form whose state will not be deleted from the store when unmounted.

This is useful for forms that may span multiple pages like wizards or signup forms on mobile devices that might span multiple navigation routes.

Type parameters​

NameType
Valuesextends FormzValues

Parameters​

NameType
__namedParametersPropsWithChildren<WebFormProps<Values>>

Returns​

Element

Defined in​

packages/react-formz-web/src/components/Form/Form.tsx:98