Narrow React Compiler dependencies in MoneyRequestReportNavigation#82785
Conversation
f4a0a8d to
498577e
Compare
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@bernhardoj Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
@marcaaron Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid.mp4Android: mWeb Chromeandroid.mweb.mp4iOS: HybridAppios.mp4iOS: mWeb Safariios.mweb.mp4MacOS: Chrome / Safariweb.mp4 |
| const searchResultsData = currentSearchResults?.data; | ||
| const searchResultsSearch = currentSearchResults?.search; | ||
| const currentAccountID = currentUserDetails.accountID; | ||
| const currentUserEmail = currentUserDetails.email ?? ''; |
There was a problem hiding this comment.
By extracting the specific sub-fields needed (.data, .accountID, etc.) into separate variables, the compiler now tracks only the fields actually used, so the computation only re-runs when its real inputs change.
This is a fairly subtle implementation that leads to a great improvement. I'm wondering if we have a best practice for documenting these scenarios yet? It seems relatively easy to perhaps reverse this change if you view these as unnecessary when actually they are signals for React compiler 🤔
Should we add something like:
// React Compiler: destructure to narrow reactive dependencies and avoid recomputes on unrelated changes
marcaaron
left a comment
There was a problem hiding this comment.
Approving but lmk your thoughts on whether to document this in the code or elsewhere.
JmillsExpensify
left a comment
There was a problem hiding this comment.
Product review not required on this one.
|
I'm the last reviewer and all remaining checks have passed, so merging. |
|
🚧 @JmillsExpensify has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
Ooops didn't mean to trigger an adhoc on this one. |
|
@OlimpiaZurek @Julesssss @marcaaron No QA steps, OK to checkoff this one? |
|
🚀 Deployed to staging by https://github.com/JmillsExpensify in version: 9.3.25-0 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 9.3.25-13 🚀
|
Explanation of Change
This PR optimizes the performance of MoneyRequestReportNavigation by narrowing the React Compiler's dependency tracking for the expensive getSections computation. Previously, the compiler tracked currentSearchResults and currentUserDetails as whole objects — any change to any field invalidated the cache and re-ran the full computation. By extracting the specific sub-fields needed (.data, .accountID, etc.) into separate variables, the compiler now tracks only the fields actually used, so the computation only re-runs when its real inputs change.
Fixed Issues
$ #83052,
Tests
Offline tests
N/A
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.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