From 3be67f5a4fd0d5173f518a47183732df67920885 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Wed, 8 Jul 2020 14:00:23 -0300 Subject: [PATCH] [FIX] Get active route returning undefined (#2257) Co-authored-by: Diego Mello --- app/utils/navigation/index.js | 6 +++--- app/views/SidebarView/index.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/utils/navigation/index.js b/app/utils/navigation/index.js index e3492df60..6f4faf6c1 100644 --- a/app/utils/navigation/index.js +++ b/app/utils/navigation/index.js @@ -46,9 +46,9 @@ export const navigationTheme = (theme) => { // Gets the current screen from navigation state export const getActiveRoute = (state) => { - const route = state.routes[state.index]; + const route = state?.routes[state?.index]; - if (route.state) { + if (route?.state) { // Dive into nested navigators return getActiveRoute(route.state); } @@ -56,4 +56,4 @@ export const getActiveRoute = (state) => { return route; }; -export const getActiveRouteName = state => getActiveRoute(state).name; +export const getActiveRouteName = state => getActiveRoute(state)?.name; diff --git a/app/views/SidebarView/index.js b/app/views/SidebarView/index.js index ab2448131..a4e2c52ca 100644 --- a/app/views/SidebarView/index.js +++ b/app/views/SidebarView/index.js @@ -141,7 +141,7 @@ class Sidebar extends Component { get currentItemKey() { const { state } = this.props; - return state.routeNames[state.index]; + return state?.routeNames[state?.index]; } renderAdmin = () => {