Closed cocbin closed 7 years ago
@cocbin 谢谢 注释掉请问使用正常不?
注释后使用正常,不过还有个很大的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()}
});
}
}
}
}
@cocbin 这个情况其实哪怕设置了右上角,也会触发到之前页面到按钮
@cocbin 我加了你的这段还是会有 我拿个透明的按钮覆盖了
@cocbin @fakefish 这个应该还是render机制问题, 暂时还没看到很好的解决方法, 目前来说最好的解决方法就是https://github.com/DickyT/react-native-tabbar-navigator/issues/16
@cocbin @fakefish Bug fixed in 0.4.0 version, please have a look
查看了下源代码,
MainTabBar.js
中第31行var defaultTabIndex = 1;
Warning: forceUpdate(...): Cannot update during an existing state transition (such as within
render). Render methods should be a pure function of props and state.
有可能是我版本原因吧, 注释掉MainTabBar.js
133行this.forceUpdate();
正常