Skip to content

Function: useChangeTracker()

useChangeTracker<TRow>(options): UseChangeTrackerReturn<TRow>

Defined in: src/tree-editor/use-change-tracker.ts:32

Track structural deltas since the last save point.

The tracker holds a snapshot of state from the last markClean() call (initially the first render’s state) and re-derives the ChangeSet by diffing it with the live state. This naturally handles:

  • undo (state reverts toward the save point → change set shrinks)
  • add-then-delete of the same id (cancels out)
  • re-parent of a previously-moved node (always reflects net parent change)

Consumers call markClean() after a successful save to reset the tracker without altering history.

Type Parameters

TRow

TRow

Parameters

options

UseChangeTrackerOptions<TRow>

Returns

UseChangeTrackerReturn<TRow>