useFormValues
React custom hook for subscribing to the entire form values.
import { useFormValues } from '@jcoreio/zod-forms'
export function useFormValues<T extends z.ZodTypeAny>(): {
parsedValues: z.output<T> | undefined
values: DeepPartial<z.input<T>> | undefined
initialParsedValues: z.output<T> | undefined
initialValues: DeepPartial<z.input<T>> | undefined
}
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.
validtedValues
- the parsed field values, orundefined
if any is invalidvalues
- the field valuesinitialParsedValues
- the initial parsed field values, orundefined
if uninitialized or any is invalidinitialValues
- the initial field values