-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Optimized context usages and set up eslint rule for optimization #28549
Optimized context usages and set up eslint rule for optimization #28549
Conversation
…y rerender in the future
Reviewer Checklist
Screenshots/VideosWebScreen.Recording.2023-10-19.at.12.05.17.movMobile Web - ChromeScreen.Recording.2023-10-19.at.12.15.54.movMobile Web - SafariScreen.Recording.2023-10-19.at.12.14.38.movDesktopScreen.Recording.2023-10-19.at.12.07.56.moviOSScreen.Recording.2023-10-19.at.12.09.45.movAndroidScreen.Recording.2023-10-19.at.12.12.50.mov |
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.
LGTM
P.S. @sebryu Please fix linter errors.
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 for this!
✋ 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: 1.3.88-0 🚀
|
🚀 Deployed to production by https://github.com/chiragsalian in version: 1.3.88-11 🚀
|
Details
Documentation for React Context states:
There is provided example of how unintended re-renders can be optimised by using
useMemo
before assigningvalue
to Context.Provider:https://react.dev/reference/react/useContext#optimizing-re-renders-when-passing-objects-and-functions
According to documentation each time we pass
value={{ var1, var2 }}
a new object is created which will trigger re-rendering of context consumers (even if var1 and var2 have been memoized).I've changed unoptimized context usages by memoizing context value.
Fixed Issues
$ #28177
PROPOSAL:
Changed unoptimized context usages by memoized context value and added eslint rule to prevent unoptimized code in the future.
Tests
Offline tests
QA Steps
This PR is more about refactoring few places, so I would doble check if pages containing refactored code are working as expected:
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
web.mov
Mobile Web - Chrome
android.web.mov
Mobile Web - Safari
ios.safari.mov
Desktop
desktop.mov
iOS
ios.mov
Android
android.mov