-
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
Merged
roryabraham
merged 11 commits into
Expensify:main
from
software-mansion-labs:kicu/concurrent-react-lets-go
Jun 26, 2024
Merged
Enable React concurrent mode #42592
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
04c47c9
Enable React concurrent mode
Kicu 28952fa
Add fixes for ReportScreen on useOnyx and patch for react-native-rean…
Kicu 09d0cf1
Add better patch fixing `react-navigation` in StrictMode
Kicu 8aa0174
Cleanup and try fixing reanimated
Kicu a29219b
Remove not needed reanimated patch for strict mode
Kicu 85250a6
Cleanup patches for react navigation
Kicu a2c8d2c
Final cleanups for concurrent mode
Kicu 0fb7bd0
Merge branch 'main' into kicu/concurrent-react-lets-go
Kicu 78b922d
Revert ReportScreenIDSetter to original version
Kicu 988f0c2
revert some changes in react concurrent mode
Kicu 60d998f
Merge branch 'main' into kicu/concurrent-react-lets-go
Kicu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
patches/@react-navigation+core+6.4.11+001+fix-react-strictmode.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
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 | ||
}, []); |
23 changes: 23 additions & 0 deletions
23
patches/react-native-reanimated+3.8.1+003+fix-strict-mode.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
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) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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. :)