Skip to content

Commit

Permalink
fix(router): fix state.routes.at is not a function (#912)
Browse files Browse the repository at this point in the history
  • Loading branch information
marklawlor committed Nov 27, 2023
1 parent 9cc9657 commit f92f699
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/expo-router/src/global-state/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function rewriteNavigationStateToParams(
) {
if (!state) return params;
// We Should always have at least one route in the state
const lastRoute = state.routes.at(-1)!;
const lastRoute = state.routes[state.routes.length - 1]!;
params.screen = lastRoute.name;
// Weirdly, this always needs to be an object. If it's undefined, it won't work.
params.params = lastRoute.params
Expand Down Expand Up @@ -167,7 +167,7 @@ function getNavigateReplaceAction(
lastNavigatorSupportingReplace: NavigationState = parentState
): NavigationAction {
// We should always have at least one route in the state
const route = state.routes.at(-1)!;
const route = state.routes[state.routes.length - 1]!;

// Only these navigators support replace
if (parentState.type === "stack" || parentState.type === "tab") {
Expand Down

0 comments on commit f92f699

Please sign in to comment.