useFormContext
React custom hook for getting the enclosing FormContextProps provided by FormProvider.
import { useFormContext } from '@jcoreio/zod-forms'
export function useFormContext<T extends z.ZodTypeAny>(): FormContextProps<T>
You must pass an explicit schema type for T unless you use the useFormContext returned by createZodForm.
Returns FormContextProps<T>
An object with the following properties:
schema- the Zod schema for the form valuesinverseSchema- the inverse Zod schema;inverseSchema.parse(values)inverts parsed values to input valuesroot- the rootFieldPathinitialize- method to initialize the form with initial valuesaddHandlers- method to register submit handlersremoveHandlers- method to unregister submit handlerssetMeta- method to set theFieldMetaof a fieldsetValue- method to set the value of a fieldsetParsedValue- method to set the parsed value of a fieldsubmit- method to trigger form submitsetSubmitStatus- method to set the submit statussubmitting- whether the form is currently submittingsubmitError- the reason submit failed, if anysubmitSucceeded- whether submit succeededsubmitFailed- whether submit failedsubmittedParsedValues- the parsed values that were submittedsubmittedValues- the values at submit timearrayActions- methods for manipulating array fieldsinsertParsed- insert a parsed value into the arrayinsert- insert a value into the arraymove- move a value from one index to anotherpop- remove the last value from the arraypushParsed- add a parsed value to the end of the arraypush- add a value to the end of the arrayremove- remove a value at an indexremoveAll- remove all valuesspliceParsed- remove and/or insert parsed values, likeArray.splicesplice- remove and/or insert values, likeArray.spliceswap- swap values at two indicesunshiftParsed- add a parsed value to the beginning of the arrayunshift- add a value to the beginning of the array
getParsedValues- get the current parsed field valuesgetValues- get the current field valuesgetInitialParsedValues- get the initial parsed field valuesgetInitialValues- get the initial field values