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! |
There was a problem hiding this comment.
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.
Sounds good, but may I suggest creating a separate PR to remove this ref?
There was a problem hiding this comment.
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;
};
}, []); |
| export default function () { | ||
| AppRegistry.runApplication(Config.APP_NAME, { | ||
| rootTag: document.getElementById('root'), | ||
| mode: 'legacy', |
There was a problem hiding this comment.
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 alleffectstwice.This behaviour ☝️ of StrictMode is the source of most bugs that happen to us.
Note:
StrictModeis 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-reanimatedfixed 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-navigationbreaks onStrictMode- fixed via local patch - need to verify the legitness of said patchreact-native-reanimatedinitial 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 Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))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
MacOS: Desktop