From 2eb5edb86b0c7e5424e9de2c5cd2f12b7554888b Mon Sep 17 00:00:00 2001 From: osdnk Date: Wed, 25 Sep 2019 16:38:20 +0200 Subject: [PATCH] fix: handle race conditions while ending transition --- src/views/Stack/StackView.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/views/Stack/StackView.tsx b/src/views/Stack/StackView.tsx index 36a8cf168..aa25bede4 100644 --- a/src/views/Stack/StackView.tsx +++ b/src/views/Stack/StackView.tsx @@ -261,8 +261,11 @@ class StackView extends React.Component { }; private handleCloseRoute = ({ route }: { route: NavigationRoute }) => { + const index = this.state.routes.findIndex(r => r.key === route.key); + // While closing route we need to point to the previous one assuming that + // this previous one in routes array this.handleTransitionComplete({ - route: this.state.routes[this.state.routes.length - 2], + route: this.state.routes[Math.max(index - 1, 0)], }); // This event will trigger when the animation for closing the route ends