React Native + react-native-router-flux:如何将hideNavBar仅应用于一个< Scene />? [英] React Native + react-native-router-flux: How to apply hideNavBar to only one <Scene/>?

查看:88
本文介绍了React Native + react-native-router-flux:如何将hideNavBar仅应用于一个< Scene />?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用react-native-router-flux的React Native中,我有两个< Scene /> ,当我应用 hideNavBar 到第一个,登录,它也适用于第二个 Home ,即使它们是在同一水平上。如何将 hideNavBar 仅应用于一个< Scene /> 登录

In React Native using react-native-router-flux, I have two <Scene/> and when I apply hideNavBar to the first one, Login, it also applies to the second, Home even though they are on the same level. How can I apply hideNavBar to only one <Scene/>, Login?

const RouterWithRedux = connect()(Router)
const store = configureStore()

export default class App extends Component {
  render() {
    return (
      <Provider store={store}>
        <RouterWithRedux>
          <Scene key='root'>
            <Scene component={Login} hideNavBar initial={true} key='login' title='Login'/>
            <Scene component={Home} key='home' title='Home'/>
          </Scene>
        </RouterWithRedux>
      </Provider>
    )
  }
}


推荐答案

我不确定原因。可能它会持续存在一些不同的 actions / PUSH 的状态参数。作为一种解决方法,你总是可以尝试明确:它对我有用。

I am not sure about the reason. Probably it persists some state parameters accross diferent actions/PUSH. As a workaround, you can always try to be explicit: it worked for me.

const RouterWithRedux = connect()(Router)
const store = configureStore()

export default class App extends Component {
  render() {
    return (
      <Provider store={store}>
        <RouterWithRedux>
          <Scene key='root'>
            <Scene component={Login} hideNavBar initial={true} key='login' title='Login'/>
            <Scene component={Home} hideNavBar={false} key='home' title='Home'/>
          </Scene>
        </RouterWithRedux>
      </Provider>
    )
  }
}

从该路线开始,NavBar可见。如果您的登录仅在整个场景流程中出现一次,这是合适的。

From that route on, NavBar is visible. It is appropriate if your Login only appears once throughout your scene flow.

这篇关于React Native + react-native-router-flux:如何将hideNavBar仅应用于一个&lt; Scene /&gt;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆