Skip to content

Commit

Permalink
Fix edge case where route was in nav state but never actually graduat…
Browse files Browse the repository at this point in the history
…ed to scene
  • Loading branch information
brentvatne committed Jul 17, 2018
1 parent 108ac0e commit cab4d71
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/views/ScenesReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit cab4d71

Please sign in to comment.