[v2] topBar customComponent does not work on Android
Issue Description
topBar customComponent does not work on Android. Component is never mounted (render function is never called).
NOTE: topBars title custom component works.
Steps to Reproduce / Code Snippets / Screenshots
Navigation.setDefaultOptions({
topBar: {
component: {
name: 'test.TopBar',
}
});
Environment
- React Native Navigation version: latest
- React Native version: latest
- Platform(s) (iOS, Android, or both?): Android
- Device info (Simulator/Device? OS version? Debug/Release?): Device Android 8.1 Debug
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 version and report back. Thank you for your contributions.
The issue has been closed for inactivity.
Im having the same issue, is anyone else? adding a custom topbar is working in ios but on android it just shows a blank topbar or a back button
Yes I'm having the same problem. It straight up shows nothing on Android (ios working fine)
@reganperkins @samcampisi Can you please add logs to componentDidMount and render to check if the component is being added and created?
From my experience, this usually happens due to flex/yoga issues
I added the logs and indeed the component is not being added. Nothing gets printed on componentDidMount.
Can you add code snippets? How are you adding the component?
Just like @FaBeyyy
Navigation.setDefaultOptions({
topBar: {
component: {
name: 'test.TopBar',
}
});
The only way I get this to work is putting the component in the title, but it's not what I'm looking for:
Navigation.setDefaultOptions({
topBar: {
title: {
component: {
name: 'test.TopBar',
}
}
});
Also I get a strange behaviour on Android while doing this, there's an unwanted padding, impossible to delete (tried giving flex: 1 to the custom title component and yet it's not covering the space)
The following api is not supported, it was supposed to be removed from iOS.
Navigation.setDefaultOptions({
topBar: {
component: {
name: 'test.TopBar'
}
}
});
We support adding two types of components to the TopBar:
- Title component:
Navigation.setDefaultOptions({
topBar: {
title: {
component: {
name: 'example.CustomTopBarTitle',
alignment: 'center'
}
}
});
- Background component (probably what you need)
Navigation.setDefaultOptions({
topBar: {
background: {
component: {
name: 'example.CustomTopBarBackground'
}
}
}
});
How do you remove the background component after you have set it using setDefaultOptions()? I don't want to set the topBar visibility to false, but instead want the default topBar back in a particular screen.