Repository navigation
Auto-track useOnyxState keys, drop declared dependencies - #8
Merged
sosek108 merged 4 commits intoNov 18, 2026
Merged
Conversation
sosek108
marked this pull request as ready for review
November 18, 2026 11:37
sosek108
merged commit Nov 18, 2026
9b4cc4a
into
feature/onyx-store-useonyxstate-recut
7 of 10 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Details
Removes the
dependenciesoption fromuseOnyxState. The hook now always tracks keys: the sharedstateProxy records the keys each selector run reads, and the hook subscribes to exactly those. A selector that readsreport_1listens to that member only, and a lookup chain follows the ID as it changes. Reading a collection root still subscribes to every member.Each run replaces the recorded set. After a commit the hook moves its subscription to the new set and re-renders if a newly read key was written in between. Recording costs one
Set.addper read on the existing Proxy, so the deep-tracking cost from https://github.com/callstack-internal/expensify-issues/issues/3042 does not apply.Measured before the option was removed (Jest on V8): auto-tracking matched hand-declared member deps exactly. Against declaring the whole collection at 1,000 rows, 5 unrelated writes ran 0 selectors instead of 5,000 (0.3 ms instead of 5 to 6 ms). Details are on the issue.
Known gap: the state view types a collection root as a member too, so
state['report_'].reportNamecompiles.Related Issues
https://github.com/callstack-internal/expensify-issues/issues/3020
Linked E/App PR
None yet. This targets the useOnyxState POC branch (Expensify#862), which has no App consumer pinned.
Automated Tests
tests/unit/useOnyxStateTest.tsxdropsdependenciesfrom every case and adds key-tracking cases: a sibling member write never runs the selector, a lookup follows the key it points at, a branch starts listening to a newly read key, and several hooks track independently. Type tests no longer passdependencies.tests/perf-test/useOnyxStateAutoDeps.perf-test.tsxcovers row and collection-root selectors.Manual Tests
None. No App code on this branch uses
useOnyxState.Author Checklist
### Related Issuessection above### Linked E/App PRsection above, and verified this change against it (E/App CI passed and manual testing completed)TestssectiontoggleReportand notonIconClick)myBool && <MyComponent />.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)Avataris modified, I verified thatAvataris working as expected in all cases)mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari