Custom topBar not working in combination with bottomTabs on iOS
Issue Description
In my app I have a centered stack where each component (view) should have a custom topBar and a sideMenu. Everything works fine with simple views (without bottomTabs). Views with bottomTabs are working on android but on iOS I am missing my custom topBar and rightButtons (rightButtons and component: TopMenu). They will not appear.
Steps to Reproduce / Code Snippets / Screenshots
see: reproducable and reduced use case in forked playground repo: forked playground with reproducable bug
Expected behavior:
- push simple: should show component with topbar (centered icon and right button)
- push complex: should show component with topbar (centered icon and right button) --> not working as expected
topBar
{
buttonColor: PROJECT_COLOR['white-light'],
backButton: {
color: PROJECT_COLOR['white-light']
},
background: {
color: PROJECT_COLOR['primary'],
},
title: {
component: {
name: 'TopMenu',
alignment: 'center',
},
},
rightButtons: [{
id: menuConfig['TOP_BAR_BURGER_ID'],
icon: require('../../assets/Burger.png')
}]
};
root
{
sideMenu: {
id: 'sideMenu',
right: {
component: {
id: menuConfig['SIDE_MENU_ID'],
name: 'Menu'
}
},
center: {
stack: {
id: 'AppRoot',
children: [{
component: {
name: screen,
passProps: passProps || {},
options: {
topBar: this.topBar,
sideMenu: this.sideMenu
}
}
}]
}
}
}
}
bottomTabs
{
options: {
bottomTabs: {
animate: true,
backgroundColor: PROJECT_COLOR['white-ultradark'],
titleDisplayMode: 'alwaysShow',
currentTabIndex: 0
}
},
children: [{
component: {
name: 'view 1',
passProps: passProps,
options: {
topBar: this.topBar,
sideMenu: this.sideMenu,
bottomTab: {
text: 'view 1',
icon: require('../../assets/icon.png'),
testID: 'VIEW_1_TAB_BAR_BUTTON',
selectedIconColor: PROJECT_COLOR['primary'],
selectedTextColor: PROJECT_COLOR['primary']
}
}
}
}, {
component: {
name: 'view 2',
passProps: passProps,
options: {
topBar: this.topBar,
sideMenu: this.sideMenu,
bottomTab: {
text: 'view 2',
icon: require('../../assets/icon.png'),
testID: 'VIEW_2_TAB_BAR_BUTTON',
selectedIconColor: PROJECT_COLOR['primary'],
selectedTextColor: PROJECT_COLOR['primary']
}
}
}
}, {
component: {
name: 'view 3',
passProps: passProps,
options: {
topBar: this.topBar,
sideMenu: this.sideMenu,
bottomTab: {
text: 'view 3',
icon: require('../../assets/icon.png'),
testID: 'VIEW_3_TAB_BAR_BUTTON',
selectedIconColor: PROJECT_COLOR['primary'],
selectedTextColor: PROJECT_COLOR['primary']
}
}
}
}]
}

Environment
- React Native Navigation version: ^2.27.9 & ^3.5.0
- React Native version: 0.59.9
- Platform(s) (iOS, Android, or both?): iOS
- Device info (Simulator/Device? OS version? Debug/Release?): Simulator e.g. iphone 8 (13.1)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.
I am on React Native 0.61.3 and RNN 4.0.4 and this still happens.
I'm having the same issue. react-native 0.61.5, RNN 4.0.9. TopBar will not appear on screens inside bottomTabs layout.
I was able to get TopBar working after wrapping my tab screens inside stack layout:
const bottomTabs = {
children: [
{
stack: {
children: [{ component: { name: 'Explore', options: { topBar } } }],
options: {
bottomTab: {
text: 'Explore',
icon: Icon,
},
},
},
},
{
stack: {
children: [{ component: { name: 'Search', options: { topBar } } }],
options: {
bottomTab: {
text: 'Search',
icon: Icon,
},
},
},
},
],
options: {
},
};
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.
The issue has been closed for inactivity.
This is still happening in current version 6.4.0 in combination with react-native 0.62.1
Thanks @hbarylskyi for the hint with wrapping the components in stack. I reworked the top bar and got it to look like it should visually. Unfortunately I did not manage to get the back button working in the topbar. It seems like there is an issue with the fact that the bottomTabs screen is being opened inside an existing stack in my case. I also tried to use pop to see if i can go back but without success.
As a workaround I am displaying the bottomTabs screen in a modal window.