DickyT / react-native-tabbar-navigator

(aka React Native Tanner Navigator) A component which builds excellent Navigator + TabBar based application, have a good solution for implementing hidesBottomBarWhenPushed in iOS.
97 stars 29 forks source link

发现两个Bug #14

Closed cocbin closed 7 years ago

cocbin commented 8 years ago
  1. 启动应用默认选中的是第二个tabbar

查看了下源代码,MainTabBar.js中第31行 var defaultTabIndex = 1;

  1. 使用setNavItems会有如下 警告

Warning: forceUpdate(...): Cannot update during an existing state transition (such as withinrender). Render methods should be a pure function of props and state. 有可能是我版本原因吧, 注释掉MainTabBar.js133行this.forceUpdate();正常

DickyT commented 8 years ago

@cocbin 谢谢 注释掉请问使用正常不?

cocbin commented 8 years ago

注释后使用正常,不过还有个很大的bug,就是使用RightButton push 一个route的时候,push后的页面就算不设置RightButton,也会在RightButton的位置残留原来的事件,导致到了第二页,点RightButton的时候还可以继续push,然后可以无限push下去。 我对源码就行了简单的修改如下勉强能用: MainTabBar.js 80行

 RightButton(route, navigator, index, navState) {
        var onPress = navState.routeStack.length-1!==index?{}:{
          onPress: () => {route.navItems.rightItem.event(self.popThisNavigator.bind(self, navigator))}
        };
        if (!route.isRoot) {
          if (route.navItems && route.navItems.rightItem) {
            if(navState.routeStack.length-1!==index) {
              return React.cloneElement(route.navItems.rightItem.component);
            } else{
              return React.cloneElement(route.navItems.rightItem.component, {
                onPress: () => {route.navItems.rightItem.event(self.popThisNavigator.bind(self, navigator))}
              });
            }
          }
        }
        else {
          var navItems = self.rootNavigatorItems;
          var currentIndex = self.currentTabIndex;
          if (navItems[currentIndex] && navItems[currentIndex].rightItem) {
            if(navState.routeStack.length-1!==index) {
              return React.cloneElement(navItems[currentIndex].rightItem.component);
            }else{
              return React.cloneElement(navItems[currentIndex].rightItem.component, {
                onPress: () => {navItems[currentIndex].rightItem.event()}
              });
            }

          }
        }
      }
fakefish commented 8 years ago

@cocbin 这个情况其实哪怕设置了右上角,也会触发到之前页面到按钮

fakefish commented 8 years ago

@cocbin 我加了你的这段还是会有 我拿个透明的按钮覆盖了

DickyT commented 8 years ago

@cocbin @fakefish 这个应该还是render机制问题, 暂时还没看到很好的解决方法, 目前来说最好的解决方法就是https://github.com/DickyT/react-native-tabbar-navigator/issues/16

DickyT commented 7 years ago

@cocbin @fakefish Bug fixed in 0.4.0 version, please have a look