useFormValues
React custom hook for subscribing to the entire form values.
import { useFormValues } from '@jcoreio/zod-forms'
export function useFormValues<T extends z.ZodTypeAny>(): {
values: z.output<T> | undefined
rawValues: unknown
initialValues: z.output<T> | undefined
initialRawValues: unknown
}
All types will be unknown
unless you pass an explicit schema type for T
or use the useFormValues
returned by createZodForm
.
Returns
An object containing the following properties. Causes a rerender when any field value changes.
values
- the parsed field values, orundefined
if any is invalidrawValues
- the raw field valuesinitialValues
- the initial field values, orundefined
if uninitialized or any is invalidrawInitialValues
- the raw initial field values