Fix edge case where route was in nav state but never actually graduated to scene

This commit is contained in:
Brent Vatne
2018-07-16 18:09:49 -07:00
parent 80257b2b0c
commit 592c19aa59

View File

@@ -130,7 +130,17 @@ export default function ScenesReducer(
return;
}
const lastScene = scenes.find(scene => scene.route.key === route.key);
const descriptor = lastScene && lastScene.descriptor;
// We can get into a weird place where we have a queued transition and then clobber
// that transition without ever actually rendering the scene, in which case
// there is no lastScene and so we need to grab the descriptor from elsewhere.
// Warning: changes to descriptor caching may break this, and in that case
// we may be better off just not adding it to stale scenes at all.
const descriptor = lastScene
? lastScene.descriptor
: descriptors[route.key];
invariant(descriptor, 'Cannot add stale scene with no descriptor');
staleScenes.set(key, {
index,