Browse Source

Fix tab bar not animating in certain cases

Arnaud Vergnet 1 year ago
parent
commit
df8f1cab24
1 changed files with 3 additions and 2 deletions
  1. 3
    2
      src/components/Tabbar/CustomTabBar.tsx

+ 3
- 2
src/components/Tabbar/CustomTabBar.tsx View File

@@ -59,6 +59,8 @@ class CustomTabBar extends React.Component<PropsType, StateType> {
59 59
     this.state = {
60 60
       translateY: new Animated.Value(0),
61 61
     };
62
+    // @ts-ignore
63
+    props.navigation.addListener('state', this.onRouteChange);
62 64
   }
63 65
 
64 66
   /**
@@ -179,7 +181,7 @@ class CustomTabBar extends React.Component<PropsType, StateType> {
179 181
     if (isFocused) {
180 182
       const stackState = route.state;
181 183
       const stackRoute =
182
-        stackState && stackState.index
184
+        stackState && stackState.index != null
183 185
           ? stackState.routes[stackState.index]
184 186
           : null;
185 187
       const params: {collapsible: Collapsible} | null | undefined = stackRoute
@@ -196,7 +198,6 @@ class CustomTabBar extends React.Component<PropsType, StateType> {
196 198
 
197 199
   render() {
198 200
     const {props, state} = this;
199
-    props.navigation.addListener('state', this.onRouteChange);
200 201
     const icons = this.getIcons();
201 202
     return (
202 203
       <Animated.View

Loading…
Cancel
Save