Skip to content
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

Update the version of react-navigation/native #37194

Merged
merged 7 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 36 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
"@react-native-google-signin/google-signin": "^10.0.1",
"@react-native-picker/picker": "2.5.1",
"@react-navigation/material-top-tabs": "^6.6.3",
"@react-navigation/native": "6.1.8",
"@react-navigation/native": "6.1.12",
"@react-navigation/native-stack": "^6.9.17",
MrRefactor marked this conversation as resolved.
Show resolved Hide resolved
"@react-navigation/stack": "6.3.16",
"@react-ng/bounds-observer": "^0.2.1",
"@rnmapbox/maps": "^10.1.11",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ index 0000000..16da117
+//# sourceMappingURL=findFocusedRouteKey.js.map
\ No newline at end of file
diff --git a/node_modules/@react-navigation/native/lib/module/useLinking.js b/node_modules/@react-navigation/native/lib/module/useLinking.js
index 6f0ac51..a77b608 100644
index 6688c62..95a0e32 100644
--- a/node_modules/@react-navigation/native/lib/module/useLinking.js
+++ b/node_modules/@react-navigation/native/lib/module/useLinking.js
@@ -2,6 +2,7 @@ import { findFocusedRoute, getActionFromState as getActionFromStateDefault, getP
Expand Down Expand Up @@ -189,17 +189,17 @@ index 6f0ac51..a77b608 100644
export default function useLinking(ref, _ref) {
let {
independent,
@@ -231,6 +270,9 @@ export default function useLinking(ref, _ref) {
@@ -234,6 +273,9 @@ export default function useLinking(ref, _ref) {
// Otherwise it's likely a change triggered by `popstate`
path !== pendingPath) {
const historyDelta = (focusedState.history ? focusedState.history.length : focusedState.routes.length) - (previousFocusedState.history ? previousFocusedState.history.length : previousFocusedState.routes.length);
+
+
+ // The historyDelta and historyDeltaByKeys may differ if the new state has an entry that didn't exist in previous state
+ const historyDeltaByKeys = getHistoryDeltaByKeys(focusedState, previousFocusedState);
if (historyDelta > 0) {
// If history length is increased, we should pushState
// Note that path might not actually change here, for example, drawer open should pushState
@@ -242,34 +284,55 @@ export default function useLinking(ref, _ref) {
@@ -245,7 +287,8 @@ export default function useLinking(ref, _ref) {
// If history length is decreased, i.e. entries were removed, we want to go back

const nextIndex = history.backIndex({
Expand All @@ -209,7 +209,8 @@ index 6f0ac51..a77b608 100644
});
const currentIndex = history.index;
try {
if (nextIndex !== -1 && nextIndex < currentIndex) {
@@ -254,27 +297,47 @@ export default function useLinking(ref, _ref) {
history.get(nextIndex - currentIndex)) {
// An existing entry for this path exists and it's less than current index, go back to that
await history.go(nextIndex - currentIndex);
+ history.replace({
Expand Down Expand Up @@ -263,7 +264,7 @@ index 6f0ac51..a77b608 100644
+ path,
+ state
+ });
+ }
+ }
}
} else {
// If no common navigation state was found, assume it's a replace
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import interceptAnonymousUser from '@libs/interceptAnonymousUser';
import getTopmostBottomTabRoute from '@libs/Navigation/getTopmostBottomTabRoute';
import Navigation from '@libs/Navigation/Navigation';
import type {RootStackParamList} from '@libs/Navigation/types';
import type {RootStackParamList, State} from '@libs/Navigation/types';
import {checkIfWorkspaceSettingsTabHasRBR, getChatTabBrickRoad} from '@libs/WorkspacesSettingsUtils';
import BottomTabBarFloatingActionButton from '@pages/home/sidebar/BottomTabBarFloatingActionButton';
import variables from '@styles/variables';
Expand All @@ -39,9 +39,9 @@ function BottomTabBar({isLoadingApp = false}: PurposeForUsingExpensifyModalProps
const navigation = useNavigation();

useEffect(() => {
const navigationState = navigation.getState();
const routes = navigationState.routes;
const currentRoute = routes[navigationState.index];
const navigationState = navigation.getState() as State<RootStackParamList> | undefined;
const routes = navigationState?.routes;
const currentRoute = routes?.[navigationState?.index ?? 0];
const bottomTabRoute = getTopmostBottomTabRoute(navigationState);
if (
// When we are redirected to the Settings tab from the OldDot, we don't want to call the Welcome.show() method.
Expand Down
4 changes: 2 additions & 2 deletions src/libs/Navigation/FreezeWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function FreezeWrapper({keepVisible = false, children}: FreezeWrapperProps) {
const currentRoute = useRoute();

useEffect(() => {
const index = navigation.getState().routes.findIndex((route) => route.key === currentRoute.key);
const index = navigation.getState()?.routes.findIndex((route) => route.key === currentRoute.key) ?? 0;
screenIndexRef.current = index;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Expand All @@ -28,7 +28,7 @@ function FreezeWrapper({keepVisible = false, children}: FreezeWrapperProps) {
// if the screen is more than 1 screen away from the current screen, freeze it,
// we don't want to freeze the screen if it's the previous screen because the freeze placeholder
// would be visible at the beginning of the back animation then
if (navigation.getState().index - (screenIndexRef.current ?? 0) > 1) {
if ((navigation.getState()?.index ?? 0) - (screenIndexRef.current ?? 0) > 1) {
InteractionManager.runAfterInteractions(() => setIsScreenBlurred(true));
} else {
setIsScreenBlurred(false);
Expand Down
4 changes: 2 additions & 2 deletions src/libs/Navigation/getTopmostBottomTabRoute.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {BottomTabName, NavigationPartialRoute, RootStackParamList, State} from './types';

function getTopmostBottomTabRoute(state: State<RootStackParamList>): NavigationPartialRoute<BottomTabName> | undefined {
const bottomTabNavigatorRoute = state.routes[0];
function getTopmostBottomTabRoute(state: State<RootStackParamList> | undefined): NavigationPartialRoute<BottomTabName> | undefined {
const bottomTabNavigatorRoute = state?.routes[0];

// The bottomTabNavigatorRoute state may be empty if we just logged in.
if (!bottomTabNavigatorRoute || bottomTabNavigatorRoute.name !== 'BottomTabNavigator' || bottomTabNavigatorRoute.state === undefined) {
Expand Down
6 changes: 3 additions & 3 deletions src/libs/actions/Welcome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {OnyxCollection} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import Navigation from '@libs/Navigation/Navigation';
import * as ReportUtils from '@libs/ReportUtils';
import type {RootStackParamList} from '@navigation/types';
import type {RootStackParamList, State} from '@navigation/types';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
Expand Down Expand Up @@ -125,15 +125,15 @@ Onyx.connect({
/**
* Shows a welcome action on first login
*/
function show(routes: NavigationState<RootStackParamList>['routes'], showEngagementModal = () => {}) {
function show(routes: State<RootStackParamList>['routes'] | undefined, showEngagementModal = () => {}) {
isReadyPromise.then(() => {
if (!isFirstTimeNewExpensifyUser) {
return;
}

// If we are rendering the SidebarScreen at the same time as a workspace route that means we've already created a workspace via workspace/new and should not open the global
// create menu right now. We should also stay on the workspace page if that is our destination.
const transitionRoute = routes.find(
const transitionRoute = routes?.find(
(route): route is NavigationState<Pick<RootStackParamList, typeof SCREENS.TRANSITION_BETWEEN_APPS>>['routes'][number] => route.name === SCREENS.TRANSITION_BETWEEN_APPS,
);
const isExitingToWorkspaceRoute = transitionRoute?.params?.exitTo === 'workspace/new';
Expand Down
Loading