[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 GitHub
parent ea10693c40
commit 53cc823dbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 // Gets the current screen from navigation state
export const getActiveRoute = (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 // Dive into nested navigators
return getActiveRoute(route.state); return getActiveRoute(route.state);
} }
@ -56,4 +56,4 @@ export const getActiveRoute = (state) => {
return route; 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() { get currentItemKey() {
const { state } = this.props; const { state } = this.props;
return state.routeNames[state.index]; return state?.routeNames[state?.index];
} }
renderAdmin = () => { renderAdmin = () => {