Reputation: 10888
I am trying to get navigation working in my React Native App. I have installed V2. The following setup does not show any tabs.
Navigation.events().registerAppLaunchedListener(()=>{
Navigation.setRoot({
root: {
topTabs: {
children:[{
stack: {
children: [
{
component: {
name: 'news.MainScreen',
text: 'tab1',
passProps: {
text: 'This is tab 1'
},
options: {
topTab: {
text: "tab 1",
testID: 'NO_IDEA'
}
}
},
},
{
component: {
name: 'news.SplashScreen',
text: 'tab2',
passProps: {
text: 'This is tab 6'
}
},
options: {
topTab: {
text: "tab 21",
testID: 'NO_IDEA_1'
}
}
},
]
}
}],
}
}
})
});
When I compile my App this is the result:
All suggestions are welcome.
Upvotes: 2
Views: 467
Reputation: 7119
This issue is reported here: https://github.com/wix/react-native-navigation/issues/4485
From documentation, you can do it as follow:
Navigation.setRoot({
root: {
topTabs: {
children: [{
stack: {
children: [{
component: {
name: 'example.FirstTabScreen',
passProps: {
text: 'This is tab 1'
}
}
}],
options: {
topTab: {
text: 'Tab 1',
icon: require('../images/one.png'),
testID: 'FIRST_TAB_BAR_BUTTON'
}
}
}
},
{
component: {
name: 'navigation.playground.TextScreen',
passProps: {
text: 'This is tab 2'
},
options: {
topTab: {
text: 'Tab 2',
icon: require('../images/two.png'),
testID: 'SECOND_TAB_BAR_BUTTON'
}
}
}
}]
}
}
});
For more information please see documentation: https://wix.github.io/react-native-navigation/#/docs/top-level-api
Upvotes: 0
Reputation: 251
it looks like you have only one tap child. try first tab only (without a stack in an tap)
Navigation.setRoot({
root: {
topTabs: {
children: [
{
component: {
name: "screens.tab1",
options: {
topTab: {
title: "Tab 1"
}
}
}
},
{
component: {
name: "screens.tab2",
options: {
topTab: {
title: "Tab 2"
}
}
}
},
{
component: {
name: "screens.tab3",
options: {
topTab: {
title: "Tab 3"
}
}
}
}
]
}
}
});
Upvotes: 1