[FIX] Get active route returning undefined (#2257)

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Djorkaeff Alexandre 2020-07-08 14:00:23 -03:00 committed by Diego Mello
parent 77917f66f0
commit 3be67f5a4f
2 changed files with 4 additions and 4 deletions

View File

@ -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;

View File

@ -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 = () => {