Repository navigation
Description
Coming from here
Background
useOnyx(key, options, dependencies) accepts an optional third argument: a React dependency list. useOnyx memoizes the output of options.selector, and dependencies tells it when to re-run that selector — needed because a selector usually closes over external values (a prop, other state) that the hook can't otherwise know changed. Separately, React Compiler already runs in the build pipeline and auto-memoizes values — including selectors — keyed on what they read.
Problem
When a useOnyx selector closes over an outside value such as a prop or other state, if the caller forgets to list that value in the dependencies array, then the selector keeps returning stale output and nothing catches it — dependencies is a plain positional argument, so react-hooks/exhaustive-deps never checks it. The argument also duplicates React's own dependency tracking, giving the codebase a second, parallel way to express when a selector should re-run.
Solution
Remove the dependencies argument from useOnyx. Selectors no longer need a manual dependency list at all: React Compiler memoizes each selector keyed on exactly the values it reads, so a stale selector from a forgotten dependency becomes impossible — there is no list to forget. Most selectors can be written inline in the useOnyx({selector}) call, or as a plain in-component function; the compiler stabilizes the selector reference (and the options object) the same way a hand-written useCallback would.
In E/App, migrate the ~70 call sites from useOnyx(key, options, deps) to useOnyx(key, options), dropping the deps array. Leave the selector inline (or a plain in-component function) for the files React Compiler compiles; add useCallback only where no-inline-useOnyx-selector errors (the handful of compiler bailouts).
Start with removing the dependencies in batches from the App and ultimately remove the argument from onyx.
One boundary to respect:
Compiler bailouts. A file React Compiler can't compile won't get this memoization, so its selector must be memoized by hand with useCallback. The rulesdir/no-inline-useOnyx-selector lint rule flags exactly these cases — it is suppressed for compiled files and errors for bailouts — so it tells you when useCallback is still required.
Onyx PR: Expensify/react-native-onyx#800
E/App PR: #93439
Issue Owner
Current Issue Owner: @hoangzinhMetadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
melvin-bot commentedon Jun 30, 2026
@fabioh8010 Huh... This is 4 days overdue. Who can take care of this?
fabioh8010 commentedon Jul 1, 2026
Working on this one today
melvin-bot commentedon Jul 6, 2026
@fabioh8010 Eep! 4 days overdue now. Issues have feelings too...
fabioh8010 commentedon Jul 8, 2026
@mountiny Could you review before I continue?
Plan: Split
useOnyxdependencies-removal into batch PRs + ESLint guardVerified facts this plan relies on
main's App wrappersrc/hooks/useOnyx.tsstill acceptsdependencies?: DependencyList(3rd param) and forwards it; Onyx onmainis3.0.88(still has the arg). → Call sites can drop the arg while the wrapper keeps accepting it. The wrapper/Onyx removal is the last step.maincontains the same 3-arg call sites this branch migrated, so each batch can be re-derived directly againstmain(this branch is the reference implementation, not a cherry-pick source — it sits on the divergent "onyx-store" engine).eslint-plugin-local-rules/(loaded viarulesdir.RULES_DIRinconfig/eslint/eslint.config.mjs, referenced asrulesdir/<name>, enabled in that file'srulesblock). Existing onyx rules (no-inline-useOnyx-selector,no-set-or-map-return-in-useOnyx-selector) live in the externaleslint-config-expensifypkg (v4.0.6).config/eslint/processors/eslint-processor-react-compiler-compat.mjsalready suppressesrulesdir/no-inline-useOnyx-selectorfor files React Compiler compiles → inline selectors are lint-clean in compilable files; only React-Compiler-bailout files needuseCallback.eslint-seatbelt(baselineconfig/eslint/eslint.seatbelt.tsv) grandfathers existing violations; never hand-edited; auto-tightens onmainafter each merge; seed a new rule's baseline withSEATBELT_INCREASE=<rule> CI=true npm run lint.Decisions
eslint-plugin-local-rules/) — it's a temporary guard (dies once Onyx drops the arg and TS enforces it).main.Change-type distribution (from full branch analysis)
WRAPPER 1 · PURE-DROP 32 · INLINE 43 · USECALLBACK 2 · RESTRUCTURE 5 (= 83).
, [deps]arg only; selector already stable (module fn / existinguseCallback/ no selector). Behavior-preserving.BaseKYCWall,CreateReportMenuItem); selector wrapped inuseCallback.MoneyRequestView,MoneyRequestConfirmationList/sections/InvoiceSenderField,hooks/useParticipantsPolicies,hooks/useParticipantsPolicyTags,Travel/TripDetailsPage.Phase 1 — PR #1: ESLint guard (land first)
Goal: forbid new 3rd-arg
useOnyxusages; grandfather existing ones so batches can proceed incrementally.New file
eslint-plugin-local-rules/no-useonyx-dependencies-arg.js(match theexport {name, meta, create}convention ofrequire-a11y-disable-justification.js):useOnyxidentifier (both@hooks/useOnyxand the restrictedreact-native-onyximport).CallExpressionvisitor also catches non-destructured calls (more robust than the sibling rules'VariableDeclaratorapproach).Wire it up in
config/eslint/eslint.config.mjsrulesblock (next to the otherrulesdir/*entries, ~line 330):Seed the seatbelt baseline (grandfather current sites):
SEATBELT_INCREASE=rulesdir/no-useonyx-dependencies-arg CI=true npm run lint, then commit the regeneratedconfig/eslint/eslint.seatbelt.tsv. From that point new/increased 3-arg usage fails CI; each batch shrinks the baseline (auto-tightened onmain).Verify:
npm run lintpasses; add a throwawayuseOnyx(k, {}, [])in a scratch file → confirm it errors; remove it.Phase 2 — Migration batches (independent PRs to
main)Each batch: branch off
main, apply the transform to its files (this branch = reference; re-derive RESTRUCTURE files againstmain's current code, don't blind-copy), then run the full per-PR verification (below). All 82 non-wrapper files are covered;src/hooks/useOnyx.tsis intentionally excluded (Phase 3).hooks/: useActiveAdminPolicies, useDefaultFundID, useExpensifyCardFeeds, useHasPerDiemTransactions, useOnboardingTaskInformation, usePaginatedReportActions, useParentReportAction, usePaymentOptions, usePolicyData/index, usePolicyForTransaction, useSplitEffectivePolicy, useDistanceRateOriginalPolicy, useTransactionThread (13)hooks/: useReportTransactions, useTransactionsByID, useTransactionViolation, useTransactionViolationOfWorkspace, useTripTransactions, useResetBankAccountModal, useReportPrimaryAction, useSelectionModeReportActions, useShouldShowEmptyReportConfirmation, useShowNotFoundPageInIOUStep, useParticipantsPolicies, useParticipantsPolicyTags (12)participants→policyIDs). Review the 2 RESTRUCTURE closely.Batches are independent (disjoint files, localized edits) → mergeable in any order/parallel; conflicts unlikely.
Per-PR verification (every batch)
npm run fmton changed files.npm run lint-changed— seatbelt count for the rule must drop for touched files (never increase).npm run typecheck— must stay green (wrapper still 3-arg, so 2-arg calls type-check fine).npm run react-compiler-compliance-check check <files>— every changed component/hook must compile; USECALLBACK files are expected to stay bailed-out (BaseKYCWall,CreateReportMenuItemalready fail onmain— confirm no new failure vsmain).npm run testfor touched areas).Phase 3 — Final PR: remove the argument (coordinated with Onyx)
Prereq: Onyx #800 merged/published (removes
dependencies, addscreateMemoizedSelector, deletesuseLiveRef) and all batches A–H merged (seatbelt baseline for the rule = 0).App final PR:
react-native-onyxto the deps-removed version (package.json + lockfile).src/hooks/useOnyx.ts: drop thedependenciesparam + stop forwarding it tooriginalUseOnyx(this is the branch's WRAPPER change).eslint-plugin-local-rules/no-useonyx-dependencies-arg.js+ its config entry + its (now-empty) seatbelt rows — redundant once TS enforces the 2-arg signature.useOnyx(..., ..., ...)that landed after the batches and migrate; add any new hooks that used the arg. Check App doesn't referenceuseLiveRef; adoptcreateMemoizedSelectoronly where genuinely needed.npm run typecheck(now the compiler enforces no 3rd arg),npm run lint,npm run test.Batch-specific Tests/QA steps
npm run test+ typecheck (pure no-ops).Execution checklist
main(parallelizable), each passing the per-PR verification; watch the seatbelt count for the rule tick down.mountiny commentedon Jul 8, 2026
@fabioh8010 Looks good! I can create the sub issues for this
83 remaining items
[-]Remove useOnyx's dependencies argument[/-][+][Due for payment 2026-08-27] Remove useOnyx's dependencies argument[/+]melvin-bot commentedon Aug 20, 2026
@hoangzinh
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.4.56-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2026-08-27. 🎊
The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]. If no checklist is needed for this issue, you can click: [no checklist button]
[-][Due for payment 2026-08-27] Remove useOnyx's dependencies argument[/-][+][Due for payment 2026-08-27] [$1000] Remove useOnyx's dependencies argument[/+]melvin-bot commentedon Aug 20, 2026
melvin-bot commentedon Aug 25, 2026
@hoangzinh Huh... This is 4 days overdue. Who can take care of this?
hoangzinh commentedon Aug 26, 2026
All done here. Just waiting for the regression period and doing payment. We don't need a C+ checklist for this issue.
melvin-bot commentedon Aug 26, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)mallenexpensify commentedon Aug 27, 2026
Payment Summary
Contributor+: @hoangzinh due $1000 via NewDot
laurenreidexpensify commentedon Aug 31, 2026
$1000 approved @hoangzinh New Expensify