React-native-router-flux: Setting status bar component for all scenes

Created on 17 Sep 2016  Â·  8Comments  Â·  Source: aksonov/react-native-router-flux

Is it possible to set Status Bar for all scenes?

Version

  • react-native-router-flux v3.35.0
  • react-native v0.33.0

Most helpful comment

@nonameolsson The error does not appear to be related to react-native-router-flux or redux. The error appears to be reporting that one of your variables is undefined in the App component. Based on the code snippet you provided I would check that the store variable is indeed defined. If it is, I would check other variables you may have in that component. Finding that rogue variable should fix your error.

Also, to add to my previous comment, you may need to add a flex: 1 style to the <View> wrapper (Ex. <View style={{ flex: 1 }}>) for it to properly render to the view.

All 8 comments

Yeah. I just add it at the root level (same as <Router/>).

<View style={styles.application}>
  <StatusBar barStyle="default"/>
  <Router/>
</View>

@alexcurtis I've already tried it. When I wrap Router with a View it does not render at all (white screen)

@sadika9 you're not going to want to wrap <Router/>. Notice in @alexcurtis' example the StatusBar component is self-closing <StatusBar barStyle="default"/>

To expand on the previous example, you will want something similar to this:

<View style={styles.application}>
    <StatusBar />
    <Router>
        <Scene key="root">
        <Scene
            key="firstComponent"
            component={FirstComponent}
            title="First Component"
            initial={true}
        />
        <Scene
            key="secondComponent"
            component={SecondComponent}
            title="Second Component"
        />
    </Scene>
    </Router>
</View>

@alexcurtis @coreyphillips Thank you

Thanks, very nice!

But when I use Redux and wrap my Router in a Provider I get an error. I'm not sure if it has to do with react-native-router-flux or Redux. What do you think?

      <View>
        <StatusBar
          backgroundColor='#303F9F'
          barStyle='light-content'
        />
        <Provider store={store}>
          <Router />
        </Provider>
      </View>

Uploading Screenshot_3.png…

@nonameolsson The error does not appear to be related to react-native-router-flux or redux. The error appears to be reporting that one of your variables is undefined in the App component. Based on the code snippet you provided I would check that the store variable is indeed defined. If it is, I would check other variables you may have in that component. Finding that rogue variable should fix your error.

Also, to add to my previous comment, you may need to add a flex: 1 style to the <View> wrapper (Ex. <View style={{ flex: 1 }}>) for it to properly render to the view.

@sadika9 I also encountered this issue about white screen, how do you solve it?

I did what alexcurtis & coreyphillips said

Was this page helpful?
0 / 5 - 0 ratings

Related issues

YouYII picture YouYII  Â·  3Comments

GCour picture GCour  Â·  3Comments

sarovin picture sarovin  Â·  3Comments

llgoer picture llgoer  Â·  3Comments

willmcclellan picture willmcclellan  Â·  3Comments