react-formbridge
Browse documentation
Core conceptsv1.0.2

State

Current reactive state returned by useFormBridge().

  • Read from it to disable buttons, show summaries, build progress UI, or inspect submit lifecycle
  • It is already derived from the schema and the current user interactions
State.tsts
1form.state.values
2form.state.errors
3form.state.touched
4form.state.dirty
5form.state.status // 'idle' | 'validating' | 'submitting' | 'success' | 'error'
6form.state.isValid
7form.state.isDirty
8form.state.isSubmitting
9form.state.isSubmitSuccess
10form.state.isSubmitError
11form.state.submitCount

Complete state shape

Complete state surface:

MethodTypeDescription
valuesSchemaValuesCurrent field values, typed from the schema. Each key matches a schema field; each value is the inferred runtime type (string, number, File, …).
errorsRecord<string, string>Per-field error messages. A key is present only when the field currently has an error; absent keys mean the field is valid. Messages are plain strings produced by the validator pipeline (Zod/Yup/Joi/Valibot/built-in).
touchedRecord<string, boolean>Per-field "has been touched" flags. A field becomes touched when the user blurs it at least once. Used to gate error visibility so forms don't scream red on first render.
dirtyRecord<string, boolean>Per-field "has been modified" flags. Set to true the first time a field's value diverges from its initial value, and cleared if the user reverts it.
status'idle' | 'validating' | 'submitting' | 'success' | 'error'Coarse lifecycle state - see FormStatus. Prefer the boolean helpers below (isSubmitting, isSubmitSuccess, …) for UI conditions.
isValidbooleantrue when errors is empty. Reflects current validation, not whether the user has attempted submit - use with submitCount if you only want to show errors after a submit attempt.
isDirtybooleantrue when at least one field is dirty. Useful for "unsaved changes" prompts and enabling Save buttons.
isSubmittingbooleantrue while status is 'submitting' or 'validating'. Use this to disable inputs or show a spinner during submission.
isSubmitSuccessbooleantrue when the last submission completed successfully.
isSubmitErrorbooleantrue when the last submission failed (threw or returned a rejection).
submitCountnumberMonotonic counter incremented on every submit attempt (successful or not). Use it as a signal that the user has tried to submit at least once.
formLevelErrorstring | nullForm-level validation error produced by cross-field rules (e.g. refine() / superRefine() in a createSchema() pipeline). null when there is no form-level validation issue.
submitErrorstring | nullError message produced by the most recent failed onSubmit call - for example an API/network error. null when the last submission succeeded or no submission has happened yet.