question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[NavigationExperimental] Bug on navigation header title effect

See original GitHub issue

In the first route, the navigation bar is hidden. In the second one, it’s visible and blue. When I swipe from one to another, you can see a rectangle with the background:

ios-bug-react-native-navigation-experimental.gif

Important code:

_renderHeader(props) {
    const { scene: { route: { navigationBarHidden } } } = props;
    return navigationBarHidden ? null : <NavigationHeader style={{backgroundColor: '#3ec4e3'}}/>;
}
_renderScene(props) {
  const { scene: { route: { Component: SceneComponent, navigationBarHidden, passProps } } } = props;

  return (
    <View>
      {navigationBarHidden ? null : this._renderHeader(props)}
      <SceneComponent navigator={this} navigatorProps={props} {...passProps} />
    </View>
  );
}

In the first route, navigationBarHidden is true.

  • React Native version: 0.32.0
  • Platform(s) (iOS, Android, or both?): iOS
  • Operating System (macOS, Linux, or Windows?): macOS 10.12

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
davidruisingercommented, Sep 23, 2016

@brunolemos besides the “bug” you have this already looks great. I wonder hwo you achieved this because I also don’t have a NavigationHeader on my first screen but when I’m sliding to go back from the second screen (where I do have a Navigation Header), the header is also visible on the first screen until the transition is completed…

ezgif com-video-to-gif

My Code looks something like this:

const _renderHeader = navigatorProps => {
  if (navigatorProps.scene.index != 0) {
    return (
      <NavBar
        title={ navigatorProps.scene.route.title }
        onLeftPress={ popScreen }
        {...navigatorProps}
      />
    )
  }
  return false
}

I would really appreciate if you could share your code.

Thanks!

0reactions
davidruisingercommented, Sep 29, 2016

@brunolemos I ended up hacking into the core components of NavigationExperimental to achieve the desired behavior. This is most likely not the way to go but it works for me for now. I uploaded the files that I used/modified to this Gist

Then I use the header like this:

  import NavigationCardStack from '..PATH_TO_MY_MODIFIED_FILES/NavigationCardStack'
  import NavBar from '..PATH_TO_MY_MODIFIED_FILES/NavBar'

  const _renderHeader = navigatorProps => (
    <NavBar
      onLeftPress={ popScreen }
      {...navigatorProps}
    />
  )

  <NavigationCardStack
    renderHeader={ _renderHeader }
    ... />

And then my initial route has a property hideNavBar

routes: [
  {
    key: 'home',
    title: 'Home',
    hideNavBar: true,
    ...
  },
]
...

NOTE: This is just something I came up quick and dirty. There are also some other modifications in the Gist that I used to further customize it to my needs. There are a lot of limitations with this (e.g. this only works if the first route has NO header, for routes coming up after you’d need to do some further tweaking). Take this as an inspiration do create your own 😉

ezgif com-video-to-gif

Read more comments on GitHub >

github_iconTop Results From Across the Web

StackNavigator reference - React Navigation
StackNavigator reference. Provides a way for your app to transition between screens where each new screen is placed on top of a stack....
Read more >
React Native Navigation - Christos Sotiriou
NavigationExperimental is the newest Navigation method from Facebook for React Native, allowing full control over navigation, ...
Read more >
React-native navigation experimental example?
I started using react-native few weeks ago. For my first app, I used navigator for the navigation with its navigationbar component to display ......
Read more >
react navigation disable animation - You.com | The AI Search ...
I want to make sure the animation happens only to the screen and not to my header component. Since the header will a...
Read more >
aksonov/react-native-router-flux - Gitter
Or are the NavigationExperimental bugs still a big barrier? ... 0.25.1 was "Fix an issue when the title in NavigationExperimentalHeader would block touches ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found