Files
react-navigation/src/getChildrenNavigationCache.js
2018-10-23 18:54:04 -07:00

17 lines
488 B
JavaScript

export default function getChildrenNavigationCache(navigation) {
if (!navigation) {
return {};
}
let childrenNavigationCache =
navigation._childrenNavigation || (navigation._childrenNavigation = {});
let childKeys = navigation.state.routes.map(route => route.key);
Object.keys(childrenNavigationCache).forEach(cacheKey => {
if (!childKeys.includes(cacheKey)) {
delete childrenNavigationCache[cacheKey];
}
});
return navigation._childrenNavigation;
}