getDirtyPaths

Returns a list of paths to dirty fields in the form. Object branches are recursed into; arrays are treated as atomic — when any descendant of an array is dirty, only the array's own path is returned.

const paths = getDirtyPaths<TSchema>(form);
const paths = getDirtyPaths<TSchema, TFieldPath>(form, config);

Generics

Parameters

Explanation

The form parameter is the form store to inspect. The optional config parameter scopes the search to a single subtree via its path property. Object branches are recursed into and clean keys are omitted; arrays are atomic, so when any descendant of an array is dirty, the result includes the array's own path rather than the paths of its individual items. Returns an empty array if the inspected subtree contains no dirty fields. When path targets a dirty array or value field, the result contains that path.

Internally, the function walks the form's field tree and asks getFieldBool whether each branch contains a dirty descendant. Because that check is itself recursive, the cost is effectively linear in field count for typical balanced forms (shallow and wide) and degrades toward O(N²) for deeply nested trees. Call this method from submit or blur handlers rather than from tight reactive loops on large forms.

Returns

Methods

Contributors

Thanks to all the contributors who helped make this page better!

  • GitHub profile picture of @fabian-hiller

Partners

Thanks to our partners who support the project ideally and financially.

Sponsors

Thanks to our GitHub sponsors who support the project financially.

  • GitHub profile picture of @stefanmaric
  • GitHub profile picture of @vasilii-kovalev
  • GitHub profile picture of @UpwayShop
  • GitHub profile picture of @ruiaraujo012
  • GitHub profile picture of @hyunbinseo
  • GitHub profile picture of @nickytonline
  • GitHub profile picture of @kibertoad
  • GitHub profile picture of @caegdeveloper
  • GitHub profile picture of @Thanaen
  • GitHub profile picture of @bmoyroud
  • GitHub profile picture of @t-lander
  • GitHub profile picture of @dslatkin