Browse Source

Fixed crash on navigation reset

Arnaud Vergnet 4 years ago
parent
commit
7295108832
1 changed files with 10 additions and 11 deletions
  1. 10
    11
      src/components/Sidebar/Sidebar.js

+ 10
- 11
src/components/Sidebar/Sidebar.js View File

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

Loading…
Cancel
Save