createForm
Creates and returns the store of the form as well as a linked Form, Field and FieldArray component.
const [form, { Form, Field, FieldArray }] = createForm<Values, ResponseData>(
options
);
If you prefer to use the library as modular as possible, you can use the
createFormStore
hook instead.
Generic
Values
FieldValues
ResponseData
Maybe<
ResponseData
> =undefined
Explanation
If you use TypeScript, you should define your field values. This way the library knows exactly which fields your form has and what values they expect. It also allows autocompletion and TypeScript notifies you of typos.
It is recommended to use
type
instead ofinterface
as this currently requires an explicit index signature in TypeScript. More about this here.
Parameter
options
Maybe<
FormOptions
>
Return
form
FormStore
Form
Form
Field
Field
FieldArray
FieldArray
Explanation
Since the Form
, Field
and FieldArray
components are already linked to your form, you don't need to add the of
property.