ericvicenti / navigation-rfc

Better Navigation in React Native
441 stars 44 forks source link

renderOverlay receives wrong scene after replace #73

Open dbasedow opened 8 years ago

dbasedow commented 8 years ago

When using a custom reducer to replace the current navigation state (using NavigationStateUtils.replaceAt) the renderOverlay function receives the wrong scene. This is because a new scene was created in the scene reducer and the previous one set to isStale=true. renderOverlay gets scenes[navigationState.index] as the scene prop.

Fixing it would be quite easy:

const key = 'scene_' + navigationState.children[navigationState.index].key;
const sceneIndex = scenes.findIndex(s => s.key == key);
...
scene: scenes[sceneIndex]

But I don't think having this stale scene around is right in this case. For me it's not that big of an issue, because I realized I don't really need the scene in renderOverlay, but keeping a stale scene around that is not involved in any animations seems a bit wasteful.