[No QA] Refactor OptionListContextProvider for React Compiler compatibility#83612
Draft
roryabraham wants to merge 5 commits intomainfrom
Draft
[No QA] Refactor OptionListContextProvider for React Compiler compatibility#83612roryabraham wants to merge 5 commits intomainfrom
roryabraham wants to merge 5 commits intomainfrom
Conversation
Move useOptionsList's options synchronization from useEffect to render-time using state-based dependency tracking. Replace the prevOptions ref with a state snapshot to avoid ref mutations during render. Co-authored-by: Cursor <cursoragent@cursor.com>
The prevReports variable and its usage in changedReportsEntries had no effect — line 102 reassigned a local variable that was never written back to the result object. Made-with: Cursor
Replace options state and all 5 useEffect hooks with a single derived value using createOptionList() during render. React Compiler will auto-memoize the call. This eliminates: - 5 effect hooks (each causing extra render passes) - eslint-disable for react-hooks/exhaustive-deps (React Compiler blocker) - Stale value bugs from suppressed dependency arrays - loadOptions, changedReportsEntries, hasInitialData computations - isEqualPersonalDetail helper - usePrevious tracking for reports, personalDetails, locale - useOnyx subscription for REPORT_ACTIONS (unused by createOptionList) - sourceValue destructuring from REPORT subscription areOptionsInitialized is now useState instead of useRef so that toggling it triggers a re-render (needed for derived options). Made-with: Cursor
Remove useMemo, useCallback wrappers from the provider and useOptionsList hook. React Compiler handles memoization automatically for compiled components. Made-with: Cursor
Consumers mounting after context is already initialized should not get stuck in a loading state. Initialize from areOptionsInitialized instead of hardcoded false. Made-with: Cursor
roryabraham
added a commit
that referenced
this pull request
Feb 26, 2026
OptionListContextProvider refactor has been moved to #83612 to keep this PR focused on the other React Compiler fixes. Made-with: Cursor
roryabraham
added a commit
that referenced
this pull request
Feb 26, 2026
OptionListContextProvider refactor has been moved to #83612 to keep this PR focused on the other React Compiler fixes. Made-with: Cursor
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.
Explanation of Change
Refactors
OptionListContextProvider.tsxfor React Compiler compatibility by:eslint-disable-next-line react-hooks/exhaustive-depssuppression that was blocking compilation.prevReportsvariable and its usage inchangedReportsEntries.useEffecthooks and associated state management with a single derivedcreateOptionList()call during render. This relies on React Compiler's automatic memoization to avoid redundant computation. ChangedareOptionsInitializedfromuseReftouseStateto properly trigger re-renders.useMemo,useCallback, anduseRefusage since the file now compiles with React Compiler.areInternalOptionsInitializedinuseOptionsListnow initializes from the context value instead of hardcodedfalse, preventing consumers that mount after initialization from getting stuck in a loading state.This is a performance-oriented refactor. By removing 5 effect hooks that were causing unnecessary re-renders and relying on React Compiler's auto-memoization, we expect a net improvement despite calling
createOptionList()during render instead of incrementally updating via effects.Split out from #83382.
Fixed Issues
$
Tests
Offline tests
QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)Screenshots/Videos
Android: Native
N/A - no UI changes
Android: mWeb Chrome
N/A - no UI changes
iOS: Native
N/A - no UI changes
iOS: mWeb Safari
N/A - no UI changes
MacOS: Chrome / Safari
N/A - no UI changes
Made with Cursor