No need to have a conditional around slicing the routes array

This commit is contained in:
Brent Vatne
2018-02-08 18:20:29 -08:00
parent 36535809cb
commit 37a3225cab

View File

@@ -243,12 +243,9 @@ export default (routeConfigs, stackConfig = {}) => {
if (state.index === lastRouteIndex && !action.params) {
return state;
}
let routes = [...state.routes];
// If we are navigating backwards in the stack (via key) the other routes
if (lastRouteIndex + 1 < routes.length) {
routes = routes.slice(0, lastRouteIndex + 1);
}
// Remove the now unused routes at the tail of the routes array
const routes = state.routes.slice(0, lastRouteIndex + 1);
// Apply params if provided, otherwise leave route identity intact
if (action.params) {