0
我使用react-navigation
來構建嵌套的TabNavigator。無法在TabNavigator中切換選項卡(react-navigation)
我的問題是我無法瀏覽到其他選項卡,直到我點擊搜索按鈕。這太奇怪了。
(UPDATE)我剛剛發現,當我更改標籤時,它只會更改「關注」或「熱門」標題。它不呈現seconrd選項卡,「常用」,並且不會切換選項卡。
這裏是第一StackNavigator(附加到根)
export default StackNavigator ({
Feedo: {
screen: FeedMainTabNavigator,
navigationOptions: {
title: 'Title',
},
},
Searcho: {
screen: SearchScreen, // if I click second tab, it doesn't show the second tab.
//But then I navigate to SearchScreen and goback to FeedScreen,
//I can see the second tab was selected.
}
}, {
lazy: true
});
這裏是FeedMainTabNavigator
export default TabNavigator({
UserFeed: {
screen: UserFeedScreen
},
PopularPost: {
screen: PopularPostScreen
},
}, {
tabBarOptions: {
style: {
backgroundColor: "#7E50CE",
overflow: "hidden"
},
activeTintColor: "white",
inactiveTintColor: "white",
tabStyle: { width: 120 },
indicatorStyle: { backgroundColor: 'white' }
}
}
);
這裏是UserFeedScreen(也許問題就在這裏?)
import {withRkTheme, RkText} from 'react-native-ui-kitten'
let ThemedNavigationBar = withRkTheme(NavBar);
import { FontAwesome } from '../../assets/icons'
class UserFeedScreen extends Component {
static navigationOptions = ({navigation}) => ({
title: 'Follow',
headerRight: (
<RkText
rkType='awesome small'
style={{color: 'white'}}
onPress={() => {navigation.navigate('Searcho')}}>{FontAwesome.search}</RkText>
),
header: (headerProps) => {
return <ThemedNavigationBar navigation={navigation} headerProps={headerProps}/>
},
})
更換
onPress={() => {navigation.navigate('Searcho')}}
我想你可以解決這個問題(+200賞金):https://stackoverflow.com/questions/47930049/how-to-reset-tabnavigator - 當用戶-日誌中取距其它屏 –