Interface UseFormHandlerStatelessReturn<Values, ExtraContext>

Type Parameters

  • Values extends BaseValues

  • ExtraContext extends Record<string, unknown>

Hierarchy

  • UseFormHandlerStatelessReturn

Properties

disabledWhileSubmitting: boolean
errors: Partial<Record<DeepKeys<Values>, string>>
extraContext: ExtraContext
initialValues: Values
isSubmitting: boolean
onSubmit: ((event: Pick<FormEvent<Element>, "preventDefault">) => Promise<void>)

Type declaration

    • (event: Pick<FormEvent<Element>, "preventDefault">): Promise<void>
    • Submit the form via a form onSubmit event.

      Throws

      Parameters

      • event: Pick<FormEvent<Element>, "preventDefault">

      Returns Promise<void>

runValidation: ((arg: {
    fieldName?: DeepKeys<Values>;
    newValues?: Values;
}) => Promise<Partial<Record<DeepKeys<Values>, string>>>)

Type declaration

    • (arg: {
          fieldName?: DeepKeys<Values>;
          newValues?: Values;
      }): Promise<Partial<Record<DeepKeys<Values>, string>>>
    • Run the validation and set the errors from the result.

      Parameters

      • arg: {
            fieldName?: DeepKeys<Values>;
            newValues?: Values;
        }
        • Optional fieldName?: DeepKeys<Values>
        • Optional newValues?: Values

      Returns Promise<Partial<Record<DeepKeys<Values>, string>>>

setErrors: ((errors: Partial<Record<DeepKeys<Values>, string>>) => void)

Type declaration

    • (errors: Partial<Record<DeepKeys<Values>, string>>): void
    • Set the entire form errors object.

      Parameters

      • errors: Partial<Record<DeepKeys<Values>, string>>

      Returns void

setFieldError: (<Name>(name: Name, error: undefined | string) => void)

Type declaration

    • <Name>(name: Name, error: undefined | string): void
    • Set a fields error

      Type Parameters

      • Name extends string

      Parameters

      • name: Name
      • error: undefined | string

      Returns void

setFieldTouched: (<Name>(name: Name, touched: boolean) => void)

Type declaration

    • <Name>(name: Name, touched: boolean): void
    • Set a fields touched state

      Type Parameters

      • Name extends string

      Parameters

      • name: Name
      • touched: boolean

      Returns void

setFieldValue: (<Name>(name: Name, value: DeepIndex<Values, Name>, shouldValidate?: boolean) => void)

Type declaration

    • <Name>(name: Name, value: DeepIndex<Values, Name>, shouldValidate?: boolean): void
    • Set a fields value

      Type Parameters

      • Name extends string

      Parameters

      • name: Name
      • value: DeepIndex<Values, Name>
      • Optional shouldValidate: boolean

      Returns void

setTouched: ((touched: FormTouched<Values>) => void)

Type declaration

    • (touched: FormTouched<Values>): void
    • Set the entire form touched set

      Parameters

      Returns void

setValues: ((values: Values, shouldValidate?: boolean) => void)

Type declaration

    • (values: Values, shouldValidate?: boolean): void
    • Update the form data in its entirity.

      Parameters

      • values: Values
      • Optional shouldValidate: boolean

      Returns void

submitForm: ((shouldValidate?: boolean) => Promise<void>)

Type declaration

    • (shouldValidate?: boolean): Promise<void>
    • Submit the form.

      Throws

      Returns

      Parameters

      • Optional shouldValidate: boolean

      Returns Promise<void>

touchOnBlur: boolean
touchOnChange: boolean
touchOnFocus: boolean
touched: FormTouched<Values>
validateOnBlur: boolean
validateOnChange: boolean
validateOnFocus: boolean
validateOnMount: boolean
validateOnSubmit: boolean
values: Values

Generated using TypeDoc