-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Perf: Split SearchRouter to State and Actions
#79753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Perf: Split SearchRouter to State and Actions
#79753
Conversation
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
dariusz-biela
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a step in the right direction.
To be sure, I checked that the original function logic was preserved and everything is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run npm run prettier
| const actionsContextValue = { | ||
| openSearchRouter, | ||
| closeSearchRouter, | ||
| toggleSearch, | ||
| registerSearchPageInput, | ||
| unregisterSearchPageInput, | ||
| }; | ||
|
|
||
| const stateContextValue = {isSearchRouterDisplayed} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally I use useMemo for context value but not sure if this is sucha a case since we have react-compiler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I let the React Compiler do its job here - I've checked the results with and without the manual memoisation, and React Compiler slightly wins!
|
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 092408d34f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@aimane-chnaif 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] |
| style={[styles.flexRow, styles.touchableButtonImage, style]} | ||
| shouldUseAutoHitSlop={shouldUseAutoHitSlop} | ||
| sentryLabel={CONST.SENTRY_LABEL.SEARCH.SEARCH_BUTTON} | ||
| // eslint-disable-next-line react-hooks/refs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ CONSISTENCY-5 (docs)
ESLint rule disables without justification can mask underlying issues and reduce code quality. Clear documentation ensures team members understand exceptions, promoting better maintainability.
Suggested fix:
Add a comment explaining why the react-hooks/refs rule needs to be disabled here. For example:
// eslint-disable-next-line react-hooks/refs -- <explanation of why this is needed>There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add comment as bot says
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is unrelated to my PR and I haven't touched the code below it, but because of the es-lint failure I decided to disable it to improve visibility of the issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aimane-chnaif Just to let you know instead of a comment I moved the function to follow the Rules of React so it can be compiled, because it turned out it's an easy one
| style={[styles.flexRow, styles.touchableButtonImage, style]} | ||
| shouldUseAutoHitSlop={shouldUseAutoHitSlop} | ||
| sentryLabel={CONST.SENTRY_LABEL.SEARCH.SEARCH_BUTTON} | ||
| // eslint-disable-next-line react-hooks/refs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add comment as bot says
| // Because of the React Compiler we don't need to memoize it manually | ||
| // eslint-disable-next-line react/jsx-no-constructed-context-values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it cause lint error without this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it does
| // Because of the React Compiler we don't need to memoize it manually | ||
| // eslint-disable-next-line react/jsx-no-constructed-context-values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, there is a lint error
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid.movAndroid: mWeb ChromeiOS: HybridAppios.moviOS: mWeb SafariMacOS: Chrome / Safariweb.mov |
|
Codex Review: Didn't find any major issues. Swish! ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
JmillsExpensify
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Product review not required.
mountiny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Mariusz, nice change!
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.3.6-0 🚀
|
|
🚀 Deployed to production by https://github.com/Beamanator in version: 9.3.6-4 🚀
|
cc: @mountiny
Explanation of Change
The PR splits the
SearchRouterContextintoStateandActionsin order to make sure, that if some component uses only state-agnostic actions doesn't re-render when the state changes.Performance of
SearchAutocompleteListbased on the browser INP metrics.Fixed Issues
$ #79353
PROPOSAL: N/A
Tests
SearchRouterseveral times to see if the app doesn't crashOffline tests
QA Steps
SearchRouterseveral times to see if the app doesn't crashPR 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
Screen.Recording.2026-01-19.at.11.54.17.mov
Android: mWeb Chrome
Screen.Recording.2026-01-19.at.11.59.24.mov
iOS: Native
Screen.Recording.2026-01-16.at.17.05.59.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-01-19.at.11.58.18.mov