[FIX] Get active route returning undefined (#2257)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
ea10693c40
commit
53cc823dbc
|
@ -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;
|
||||
|
|
|
@ -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 = () => {
|
||||
|
|
Loading…
Reference in New Issue