解决react-native-scrollable-tab-view库在android 端执行两次onChangeTab事件
<ScrollableTabView
style={styles.scrollViewStyle}
initialPage={0}
renderTabBar={() => <ScrollableTabBar/>}
tabBarUnderlineStyle={[styles.lineStyle]}
tabBarTextStyle={styles.tabStyle}
// 暂时解决android onChangeTab渲染两次的问题
onChangeTab={({i, from}) => i != from && this.tabChangeHandler(i)}
>
<View tabLabel={'tab1'}><Text>11 </Text></View>
<View tabLabel={'tab2'}><Text>12 </Text></View>
</ScrollableTabView>
tabChangeHandler(i, ref, from) {
console.log(i, ref, from)
...
}
网友评论