react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

[v2] topBar customComponent does not work on Android

Open FaBeyyy opened this issue 8 years ago • 10 comments

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

FaBeyyy avatar Jun 16 '18 16:06 FaBeyyy

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.

stale[bot] avatar Jul 31 '18 17:07 stale[bot]

The issue has been closed for inactivity.

stale[bot] avatar Aug 07 '18 17:08 stale[bot]

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

reganperkins avatar Aug 13 '18 20:08 reganperkins

Yes I'm having the same problem. It straight up shows nothing on Android (ios working fine)

samcampisi avatar Aug 29 '18 06:08 samcampisi

@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

guyca avatar Aug 29 '18 08:08 guyca

I added the logs and indeed the component is not being added. Nothing gets printed on componentDidMount.

samcampisi avatar Aug 29 '18 09:08 samcampisi

Can you add code snippets? How are you adding the component?

guyca avatar Aug 29 '18 10:08 guyca

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)

samcampisi avatar Aug 29 '18 12:08 samcampisi

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:

  1. Title component:

Navigation.setDefaultOptions({
  topBar: {
    title: {
      component: {
        name: 'example.CustomTopBarTitle',
        alignment: 'center'
      }
  }
});
  1. Background component (probably what you need)

Navigation.setDefaultOptions({
  topBar: {
    background: {
      component: {
        name: 'example.CustomTopBarBackground'
      }
    }
  }
});

guyca avatar Aug 29 '18 13:08 guyca

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.

Anarcho-X avatar Sep 09 '18 12:09 Anarcho-X