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: @fabioh8010
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: @fabioh8010