Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5048,15 +5048,15 @@ const CONST = {
REPLACE: 'REPLACE',
PUSH: 'PUSH',
NAVIGATE: 'NAVIGATE',
NAVIGATE_DEPRECATED: 'NAVIGATE_DEPRECATED',
SET_PARAMS: 'SET_PARAMS',
PRELOAD: 'PRELOAD',
POP_TO: 'POP_TO',

/** These action types are custom for RootNavigator */
DISMISS_MODAL: 'DISMISS_MODAL',
OPEN_WORKSPACE_SPLIT: 'OPEN_WORKSPACE_SPLIT',
SET_HISTORY_PARAM: 'SET_HISTORY_PARAM',
REPLACE_PARAMS: 'REPLACE_PARAMS',
PRELOAD: 'PRELOAD',
},
},
TIME_PERIOD: {
Expand Down
14 changes: 2 additions & 12 deletions src/libs/Navigation/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
];

let account: OnyxEntry<Account>;
Onyx.connect({

Check warning on line 47 in src/libs/Navigation/Navigation.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.ACCOUNT,
callback: (value) => {
account = value;
Expand Down Expand Up @@ -305,15 +305,6 @@
return;
}

/**
* In react-navigation 7 the behavior of the `navigate` function has slightly changed.
* If it detects that a screen that we want to navigate to is already in the stack, it doesn't go back anymore.
* More: https://reactnavigation.org/docs/upgrading-from-6.x#the-navigate-method-no-longer-goes-back-use-popto-instead
*/
if (minimalAction.type === CONST.NAVIGATION.ACTION_TYPE.NAVIGATE) {
minimalAction.type = CONST.NAVIGATION.ACTION_TYPE.NAVIGATE_DEPRECATED;
}

const indexOfBackToRoute = targetState.routes.findLastIndex((route) => doesRouteMatchToMinimalActionPayload(route, minimalAction, compareParams));
const distanceToPop = targetState.routes.length - indexOfBackToRoute - 1;

Expand All @@ -325,11 +316,10 @@
}

/**
* If we are not comparing params, we want to use navigate action because it will replace params in the route already existing in the state if necessary.
* This part will need refactor after migrating to react-navigation 7. We will use popTo instead.
* If we are not comparing params, we want to use popTo action because it will replace params in the route already existing in the state if necessary.
*/
if (!compareParams) {
navigationRef.current.dispatch(minimalAction);
navigationRef.current.dispatch({...minimalAction, type: CONST.NAVIGATION.ACTION_TYPE.POP_TO});
return;
}

Expand Down
Loading