Skip to content

fix(proxy-state-tree): add missing stopTracking() method to TrackStateTree#651

Closed
ericsorenson wants to merge 0 commit intocerebral:nextfrom
ericsorenson:next
Closed

fix(proxy-state-tree): add missing stopTracking() method to TrackStateTree#651
ericsorenson wants to merge 0 commit intocerebral:nextfrom
ericsorenson:next

Conversation

@ericsorenson
Copy link
Copy Markdown
Collaborator

Summary

  • Add missing stopTracking() method to TrackStateTree class and ITrackStateTree interface in proxy-state-tree
  • Vue (v2, v3) and Svelte integrations call tree.stopTracking() on every component update, but the method didn't exist, causing a TypeError at runtime
  • The fix delegates to this.root.unsetTrackStateTree(this), mirroring how subscribe() already stops tracking internally
  • Add unit test verifying state accesses after stopTracking() are not recorded

The React integration skips stopTracking() entirely. It goes straight from track() to subscribe(), and subscribe() already calls this.root.unsetTrackStateTree(this) as its first line. So React never needed a separate stopTracking(), untracking happens implicitly when it subscribes. Vue and Svelte have a different render lifecycle where they call stopTracking() explicitly between tracking and subscribing, which is why only those integrations hit the TypeError.

@codesandbox
Copy link
Copy Markdown

codesandbox Bot commented Mar 21, 2026

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@ericsorenson
Copy link
Copy Markdown
Collaborator Author

After a conversation, we decided to stop using stopTracking and follow the pattern used for React.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant