From f92f69943a05ef4b2ef66837a75996ceb3ef9f72 Mon Sep 17 00:00:00 2001 From: Mark Lawlor Date: Mon, 27 Nov 2023 11:22:13 +1000 Subject: [PATCH] fix(router): fix state.routes.at is not a function (#912) --- packages/expo-router/src/global-state/routing.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/expo-router/src/global-state/routing.ts b/packages/expo-router/src/global-state/routing.ts index ef6c88f7..f63a9bfb 100644 --- a/packages/expo-router/src/global-state/routing.ts +++ b/packages/expo-router/src/global-state/routing.ts @@ -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 @@ -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") {