Skip to content
This repository has been archived by the owner on Feb 25, 2020. It is now read-only.

Commit

Permalink
fix: don't keep descriptors for routes that have been removed
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Sep 14, 2019
1 parent 660403b commit 50cd4d5
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/navigators/createNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,16 @@ function createNavigator(NavigatorView, router, navigationConfig) {
);
}

const descriptors = {};

routes.forEach(route => {
const descriptors = routes.reduce((acc, route) => {
if (
prevDescriptors &&
prevDescriptors[route.key] &&
route === prevDescriptors[route.key].state &&
screenProps === currentState.screenProps &&
currentState.themeContext === currentState.theme
) {
descriptors[route.key] = prevDescriptors[route.key];
return;
acc[route.key] = prevDescriptors[route.key];
return acc;
}
const getComponent = router.getComponentForRouteName.bind(
null,
Expand All @@ -57,14 +55,15 @@ function createNavigator(NavigatorView, router, navigationConfig) {
screenProps,
currentState.themeContext
);
descriptors[route.key] = {
acc[route.key] = {
key: route.key,
getComponent,
options,
state: route,
navigation: childNavigation,
};
});
return acc;
}, {});

return { descriptors, screenProps, theme: state.themeContext };
}
Expand Down

0 comments on commit 50cd4d5

Please sign in to comment.