From 135c6be0741a51fa21749e7842279817cbd64ece Mon Sep 17 00:00:00 2001 From: Vit Horacek <vit@expensify.com> Date: Wed, 3 Jul 2024 17:37:44 +0100 Subject: [PATCH] Revert "Merge pull request #42592 from software-mansion-labs/kicu/concurrent-react-lets-go" This reverts commit d047467a65b19e2ea99f4af3c0ff76481849a4f7, reversing changes made to 04f6598c4e7f08672fff1e7f403dbe34813338ce. --- ...core+6.4.11+001+fix-react-strictmode.patch | 44 ---------- ...reanimated+3.8.1+003+fix-strict-mode.patch | 25 +----- src/App.tsx | 88 +++++++++---------- src/CONFIG.ts | 1 - src/setup/platformSetup/index.website.ts | 1 + 5 files changed, 43 insertions(+), 116 deletions(-) delete mode 100644 patches/@react-navigation+core+6.4.11+001+fix-react-strictmode.patch diff --git a/patches/@react-navigation+core+6.4.11+001+fix-react-strictmode.patch b/patches/@react-navigation+core+6.4.11+001+fix-react-strictmode.patch deleted file mode 100644 index 8941bb380a79..000000000000 --- a/patches/@react-navigation+core+6.4.11+001+fix-react-strictmode.patch +++ /dev/null @@ -1,44 +0,0 @@ -diff --git a/node_modules/@react-navigation/core/lib/module/useNavigationBuilder.js b/node_modules/@react-navigation/core/lib/module/useNavigationBuilder.js -index 051520b..6fb49e0 100644 ---- a/node_modules/@react-navigation/core/lib/module/useNavigationBuilder.js -+++ b/node_modules/@react-navigation/core/lib/module/useNavigationBuilder.js -@@ -174,10 +174,6 @@ export default function useNavigationBuilder(createRouter, options) { - getIsInitial - } = React.useContext(NavigationStateContext); - const stateCleanedUp = React.useRef(false); -- const cleanUpState = React.useCallback(() => { -- setCurrentState(undefined); -- stateCleanedUp.current = true; -- }, [setCurrentState]); - const setState = React.useCallback(state => { - if (stateCleanedUp.current) { - // State might have been already cleaned up due to unmount -@@ -291,6 +287,9 @@ export default function useNavigationBuilder(createRouter, options) { - // So we override the state object we return to use the latest state as soon as possible - state = nextState; - React.useEffect(() => { -+ // In strict mode, React will double-invoke effects. -+ // So we need to reset the flag if component was not unmounted -+ stateCleanedUp.current = false; - setKey(navigatorKey); - if (!getIsInitial()) { - // If it's not initial render, we need to update the state -@@ -300,14 +299,10 @@ export default function useNavigationBuilder(createRouter, options) { - } - return () => { - // We need to clean up state for this navigator on unmount -- // We do it in a timeout because we need to detect if another navigator mounted in the meantime -- // For example, if another navigator has started rendering, we should skip cleanup -- // Otherwise, our cleanup step will cleanup state for the other navigator and re-initialize it -- setTimeout(() => { -- if (getCurrentState() !== undefined && getKey() === navigatorKey) { -- cleanUpState(); -- } -- }, 0); -+ if (getCurrentState() !== undefined && getKey() === navigatorKey) { -+ setCurrentState(undefined); -+ stateCleanedUp.current = true; -+ } - }; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); diff --git a/patches/react-native-reanimated+3.8.1+003+fix-strict-mode.patch b/patches/react-native-reanimated+3.8.1+003+fix-strict-mode.patch index ccc208062d10..bd9c5da55f0e 100644 --- a/patches/react-native-reanimated+3.8.1+003+fix-strict-mode.patch +++ b/patches/react-native-reanimated+3.8.1+003+fix-strict-mode.patch @@ -10,27 +10,4 @@ index 3404e89..b545cb6 100644 + // react_native_assert(reanimatedCommitFlag_ != true); reanimatedCommitFlag_ = true; } - -diff --git a/node_modules/react-native-reanimated/lib/module/reanimated2/UpdateProps.js b/node_modules/react-native-reanimated/lib/module/reanimated2/UpdateProps.js -index e69c581..78b7034 100644 ---- a/node_modules/react-native-reanimated/lib/module/reanimated2/UpdateProps.js -+++ b/node_modules/react-native-reanimated/lib/module/reanimated2/UpdateProps.js -@@ -7,14 +7,11 @@ import { isFabric, isJest, shouldBeUseWeb } from './PlatformChecker'; - import { runOnUIImmediately } from './threads'; - let updateProps; - if (shouldBeUseWeb()) { -- updateProps = (_, updates, maybeViewRef, isAnimatedProps) => { -+ updateProps = (viewDescriptorsSet, updates, maybeViewRef, isAnimatedProps) => { - 'worklet'; -- -- if (maybeViewRef) { -- maybeViewRef.items.forEach((item, _index) => { -- _updatePropsJS(updates, item, isAnimatedProps); -- }); -- } -+ viewDescriptorsSet.value.forEach((viewDescriptor) => { -+ _updatePropsJS(updates, {_component: viewDescriptor.tag}, isAnimatedProps); -+ }) - }; - } else { - updateProps = (viewDescriptors, updates) => { + diff --git a/src/App.tsx b/src/App.tsx index 21025d34a661..1ce17ea095bd 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -31,7 +31,6 @@ import {CurrentReportIDContextProvider} from './components/withCurrentReportID'; import {EnvironmentProvider} from './components/withEnvironment'; import {KeyboardStateProvider} from './components/withKeyboardState'; import {WindowDimensionsProvider} from './components/withWindowDimensions'; -import CONFIG from './CONFIG'; import Expensify from './Expensify'; import useDefaultDragAndDrop from './hooks/useDefaultDragAndDrop'; import {ReportIDsContextProvider} from './hooks/useReportIDs'; @@ -53,56 +52,51 @@ LogBox.ignoreLogs([ const fill = {flex: 1}; -const StrictModeWrapper = CONFIG.USE_REACT_STRICT_MODE ? React.StrictMode : ({children}: {children: React.ReactElement}) => children; - function App({url}: AppProps) { useDefaultDragAndDrop(); OnyxUpdateManager(); - return ( - <StrictModeWrapper> - <InitialURLContextProvider url={url}> - <GestureHandlerRootView style={fill}> - <ComposeProviders - components={[ - OnyxProvider, - ThemeProvider, - ThemeStylesProvider, - ThemeIllustrationsProvider, - SafeAreaProvider, - PortalProvider, - SafeArea, - LocaleContextProvider, - HTMLEngineProvider, - WindowDimensionsProvider, - KeyboardStateProvider, - PopoverContextProvider, - CurrentReportIDContextProvider, - ScrollOffsetContextProvider, - ReportAttachmentsProvider, - PickerStateProvider, - EnvironmentProvider, - CustomStatusBarAndBackgroundContextProvider, - ActiveElementRoleProvider, - ActiveWorkspaceContextProvider, - ReportIDsContextProvider, - PlaybackContextProvider, - FullScreenContextProvider, - VolumeContextProvider, - VideoPopoverMenuContextProvider, - KeyboardProvider, - ]} - > - <CustomStatusBarAndBackground /> - <ErrorBoundary errorMessage="NewExpensify crash caught by error boundary"> - <ColorSchemeWrapper> - <Expensify /> - </ColorSchemeWrapper> - </ErrorBoundary> - </ComposeProviders> - </GestureHandlerRootView> - </InitialURLContextProvider> - </StrictModeWrapper> + <InitialURLContextProvider url={url}> + <GestureHandlerRootView style={fill}> + <ComposeProviders + components={[ + OnyxProvider, + ThemeProvider, + ThemeStylesProvider, + ThemeIllustrationsProvider, + SafeAreaProvider, + PortalProvider, + SafeArea, + LocaleContextProvider, + HTMLEngineProvider, + WindowDimensionsProvider, + KeyboardStateProvider, + PopoverContextProvider, + CurrentReportIDContextProvider, + ScrollOffsetContextProvider, + ReportAttachmentsProvider, + PickerStateProvider, + EnvironmentProvider, + CustomStatusBarAndBackgroundContextProvider, + ActiveElementRoleProvider, + ActiveWorkspaceContextProvider, + ReportIDsContextProvider, + PlaybackContextProvider, + FullScreenContextProvider, + VolumeContextProvider, + VideoPopoverMenuContextProvider, + KeyboardProvider, + ]} + > + <CustomStatusBarAndBackground /> + <ErrorBoundary errorMessage="NewExpensify crash caught by error boundary"> + <ColorSchemeWrapper> + <Expensify /> + </ColorSchemeWrapper> + </ErrorBoundary> + </ComposeProviders> + </GestureHandlerRootView> + </InitialURLContextProvider> ); } diff --git a/src/CONFIG.ts b/src/CONFIG.ts index 8800cc907588..9ed4242d7604 100644 --- a/src/CONFIG.ts +++ b/src/CONFIG.ts @@ -96,5 +96,4 @@ export default { IOS_CLIENT_ID: '921154746561-s3uqn2oe4m85tufi6mqflbfbuajrm2i3.apps.googleusercontent.com', }, GCP_GEOLOCATION_API_KEY: googleGeolocationAPIKey, - USE_REACT_STRICT_MODE: true, } as const; diff --git a/src/setup/platformSetup/index.website.ts b/src/setup/platformSetup/index.website.ts index 07917e0e6f65..77c373957510 100644 --- a/src/setup/platformSetup/index.website.ts +++ b/src/setup/platformSetup/index.website.ts @@ -53,6 +53,7 @@ const webUpdater = (): PlatformSpecificUpdater => ({ export default function () { AppRegistry.runApplication(Config.APP_NAME, { rootTag: document.getElementById('root'), + mode: 'legacy', }); // When app loads, get current version (production only)