From df8f1cab24faafbb08714bc73fa6f063d9b7c2f2 Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Wed, 23 Sep 2020 09:20:06 +0200 Subject: [PATCH] Fix tab bar not animating in certain cases --- src/components/Tabbar/CustomTabBar.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/Tabbar/CustomTabBar.tsx b/src/components/Tabbar/CustomTabBar.tsx index cd18b82..0f926d4 100644 --- a/src/components/Tabbar/CustomTabBar.tsx +++ b/src/components/Tabbar/CustomTabBar.tsx @@ -59,6 +59,8 @@ class CustomTabBar extends React.Component { this.state = { translateY: new Animated.Value(0), }; + // @ts-ignore + props.navigation.addListener('state', this.onRouteChange); } /** @@ -179,7 +181,7 @@ class CustomTabBar extends React.Component { if (isFocused) { const stackState = route.state; const stackRoute = - stackState && stackState.index + stackState && stackState.index != null ? stackState.routes[stackState.index] : null; const params: {collapsible: Collapsible} | null | undefined = stackRoute @@ -196,7 +198,6 @@ class CustomTabBar extends React.Component { render() { const {props, state} = this; - props.navigation.addListener('state', this.onRouteChange); const icons = this.getIcons(); return (