Repository navigation
Description
coming from this proposal
Background
Selectors in react-native-onyx are functions that allow to subscribe a subset of data from storage, providing performance benefits by only re-rendering components when the selected data changes, rather than when any property in the entire object changes. They transform, filter, or extract specific data and support type-safe operations on both individual keys and collections.
Recently we merged a couple of improvements to useOnyx, including the memoization working properly with stable references. However, most of our codebase still uses inline selectors, which prevents us from taking advantage of these optimizations.
Problem
When using selectors in useOnyx, if you define the selector as inline function directly in the options object, then the memoization system breaks causing unnecessary re-computations and re-renders on every component update.
Solution
Make selectors first-class citizens in E/App by organizing them according to their usage scope:
- Shared selectors: if a selector is reused across multiple components, define it in a dedicated selectors/ directory so it can be consistently imported and reused.
- Local selectors: if a selector exists purely for the needs of a single component or hook, define it in the same file outside the component where it’s used to avoid unnecessary abstraction.
- Contextual selectors: if a selector relies on additional data from the component itself, define it as a useCallback inside the component, with the relevant data passed as dependencies.
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~021965762166257784585
- Upwork Job ID: 1965762166257784585
- Last Price Increase: 2025-11-10
Issue Owner
Current Issue Owner: @TMisiukiewiczSub-issues
Collapse Sub-issuesSub-issues
Metadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
melvin-bot commentedon Sep 10, 2025
Triggered auto assignment to @heyjennahay (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.[-]Forbid inline useOnyx selectors[/-][+][$250] Forbid inline useOnyx selectors[/+]melvin-bot commentedon Sep 10, 2025
Job added to Upwork: https://www.upwork.com/jobs/~021965762166257784585
melvin-bot commentedon Sep 10, 2025
Triggered auto assignment to Contributor-plus team member for initial proposal review - @dukenv0307 (
External)68 remaining items
melvin-bot commentedon Nov 14, 2025
Payment Summary
Upwork Job
BugZero Checklist (@heyjennahay)
heyjennahay commentedon Nov 18, 2025
Confirming payment summary:
twisterdotcom commentedon Nov 19, 2025
@dukenv0307 has submitted payment for this report on ND here.
SO: https://stackoverflowteams.com/c/expensify/questions/7582
Zapier Logs
Run ID: 00040eee-e10b-ae64-c793-872848369441melvin-bot commentedon Nov 27, 2025
@dukenv0307 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!
melvin-bot commentedon Dec 4, 2025
This issue has not been updated in over 14 days. @carlosmiceli, @heyjennahay, @TMisiukiewicz, @dukenv0307 eroding to Weekly issue.
heyjennahay commentedon Dec 5, 2025
Looks like we're all done here. Thanks everyone for your work 👍