react-hook-form
Advanced tools
Changelog
[7.44.0] - 2023-06-14
<Form />
component// Send post request with formData
<Form
action="/api"
control={control}
onSuccess={() => {
alert("Great");
}}
/>
// Send post request with json form data
<Form action="/api" encType="application/json" headers={{ accessToken: 'test' }}>
{errors.root?.server.type === 500 && 'Error message'}
{errors.root?.server.type === 400 && 'Error message'}
</Form>
// Send post request with formData with fetch
<Form
onSubmit={async ({ formData, data, formDataJson, event }) => {
await fetch("api", {
method: "post",
body: formData,
});
}}
/>
TransformedValues
with useFormContext
useFormContext<FormValue, TransformedValues>()
TTransformedValues
to FormProvider
FormProviderProps<TFieldValues, TContext, TTransformedValues>