Files
react-navigation/packages/core/src/getChildrenNavigationCache.js
Brent Vatne 78d8548f31 Merge pull request #25 from rimzici/master
Do not clear navigation child from cache while transitioning
2018-12-02 12:55:33 -08:00

17 lines
525 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) && !navigation.state.isTransitioning) {
delete childrenNavigationCache[cacheKey];
}
});
return navigation._childrenNavigation;
}