-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Enable React concurrent mode #42592
Enable React concurrent mode #42592
Conversation
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
@@ -40,4 +40,4 @@ function TextInputClearButton({onPressButton}: TextInputClearButtonProps) { | |||
|
|||
TextInputClearButton.displayName = 'TextInputClearButton'; | |||
|
|||
export default forwardRef(TextInputClearButton); |
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 unrelated but a source of warning in browser console - the ref was unused.
While working on updated React I wanted to get rid of as many console warnings as I can since it helps to find the actual React bugs
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.
Sounds good, but may I suggest creating a separate PR to remove this ref?
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.
Can you please revert this change as it's done in #44155
8dd4c17
to
b3ff01b
Compare
190c401
to
831a491
Compare
|
831a491
to
875756f
Compare
As a follow up to @Kicu mentioning react-navigation 7. This version introduces two functionalities that we may be interested in:
|
875756f
to
24fa270
Compare
24fa270
to
a2c8d2c
Compare
@rayane-djouah 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] |
@mountiny @roryabraham We're ready for liftoff 🚀 Web and native builds work, there are no crucial issues and app works. Now I think we need some heavy testing by QA's - I tested only the basic functionalities that I know about. If any bugs come up they could be rather tricky or non-obvious. |
Maybe we could open another PR with all the changes not strictly related to the |
I'm not sure. Technically it will be easy to split this into
So maybe leaving this PR as is will just be simpler? |
@Kicu @roryabraham I'm having trouble following how this code only runs on dev considering that the I'm mainly asking because there's a crash happening here on staging that involves a component exceeding the max update depth. |
Hmm taking a deeper look at the docs it seems there's logic within React's StrictMode implementation that prevents it from running effects twice on staging/production builds. |
@jasperhuangg indeed its the internal behavior of StrictMode, described in the React docs that makes it only work in dev. The CONFIG flag is for the convenience of developers for quick testing locally why their code fails |
🚀 Deployed to production by https://github.com/jasperhuangg in version: 9.0.3-7 🚀
|
🚀 Deployed to production by https://github.com/Julesssss in version: 9.0.5-13 🚀
|
👋 The introduction of concurrent mode caused Left hand menu and RHP to not open instantly when opening from link The issue was fixed by PR #45778 |
👋 The introduction of Strict Mode will unmount then remount component on the first render
see here Bad const isUnmounted = useRef(false);
useEffect(() => {
return () => {
isUnmounted.current = true;
};
}, []); Good const isUnmounted = useRef(null);
useEffect(() => {
isUnmounted.current = false; // remount will back value to false
return () => {
isUnmounted.current = true;
};
}, []); |
@@ -53,7 +53,6 @@ const webUpdater = (): PlatformSpecificUpdater => ({ | |||
export default function () { | |||
AppRegistry.runApplication(Config.APP_NAME, { | |||
rootTag: document.getElementById('root'), | |||
mode: 'legacy', |
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.
Coming from #47041, our app has some infinite Lottie animations. In concurrent mode, when the SidebarScreen is suspended (i.e., Suspense
feature), it conflicts with these animations, preventing the animation component from rendering. :)
Glossary
React concurrent mode
Starting from react 18 we can run React in new concurrent way (which seems the way React team is moving). Concurrent mode enables a lot of new behaviours in react, most importantly renders can be interrupted by React, re-run or run more than once. This is supposed to make react more performant and webapps more responsive to user actions.
State of this in Expensify:
Further reading:
React StrictMode
<StrictMode>
is a component that wraps the whole App in (or parts of App) and it runs extra checks and extra behaviors only in dev. So in essence it's a kind of devtool for developers, that should help catch tricky bugs that could be introduced when running concurrent mode. Mainly it renders every component twice (discarding the first render) and runs alleffects
twice.This behaviour ☝️ of StrictMode is the source of most bugs that happen to us.
Note:
StrictMode
is not needed for concurrent react to work but it is much safer to use it.https://react.dev/reference/react/StrictMode
Details
This PR enables running React 18+ in concurrent mode alongside using StrictMode.
I did not provide screenshots or videos because this affects the whole how React behaves, so in theory affects the whole app.
Done
<StrictMode>
react-native-reanimated
fixed via patch, however it should be released soon as the team is aware of StrictMode problems.The related upstream PRs are: Fix web exiting animation in StrictMode software-mansion/react-native-reanimated#6129 and Merge ViewDescriptors implementation software-mansion/react-native-reanimated#6123 and reanimated team expects correct version to be released in 2.13
List of known bugs & fixes
solvedreact-navigation
breaks onStrictMode
- fixed via local patch - need to verify the legitness of said patchreact-native-reanimated
initial animation when entering Report sometimes flickers; this happens because of StrictMode so only in devFixed Issues
$ #33531
PROPOSAL:
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.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
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop