mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-05-04 20:21:07 +08:00
17 lines
488 B
JavaScript
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;
|
|
}
|