Fixed crash on navigation reset

This commit is contained in:
Arnaud Vergnet 2020-04-06 14:39:29 +02:00
parent 4c746a0b60
commit 7295108832

View file

@ -161,18 +161,17 @@ class SideBar extends React.Component<Props, State> {
} }
onRouteChange = (event) => { onRouteChange = (event) => {
if (event.data.state.routes !== undefined) { try {
const route = event.data.state.routes[0]; // get the current route (ROOT) const state = event.data.state.routes[0].state; // Get the Drawer's state if it exists
if (route.state !== undefined) { // Get the current route name. This will only show Drawer routes.
const state = route.state; // Get the Drawer's state if it exists // Tab routes will be shown as 'Main'
// Get the current route name. This will only show Drawer routes. const routeName = state.routeNames[state.index];
// Tab routes will be shown as 'Main' if (this.state.activeRoute !== routeName)
const routeName = state.routeNames[state.index]; this.setState({activeRoute: routeName});
if (this.state.activeRoute !== routeName) } catch(e) {
this.setState({activeRoute: routeName}); this.setState({activeRoute: 'Main'});
}
} }
}; };
showDisconnectDialog = () => this.setState({dialogVisible: true}); showDisconnectDialog = () => this.setState({dialogVisible: true});