fn
useFormContext
v0.0.16testeddemoRetrieve the {@link useForm} instance provided by an ancestor, for building field components that live anywhere in the form's subtree. Returns `null` when no form has been provided (so callers can support standalone use).
Example
ts
// Inside a custom <TextField> rendered within a useForm() component:
const form = useFormContext();
if (form)
form.setFieldValue('email', 'a@b.com');Demo
Loading demo…
Signature
ts
export function useFormContext<TInput extends object = any, TOutput = TInput>(): UseFormReturn<TInput, TOutput> | null{ ... }Type Parameters
TInputextends object= anyTOutput= TInputReturns
UseFormReturn<TInput, TOutput> | nullThe injected form instance, or `null`