当前位置: 动力学知识库 > 问答 > 编程问答 >

reactjs - How to set Dashboard screen with drawer as initial root in Navigator in react-native

问题描述:

I have set Initial root as LoginScreen in Navigator (component of react-native).

But after login I want DashboardScreen having drawer as initial root for navigation drawer present in DashboardScreen

In App.js for login initial root:

<Navigator

style={styles.container}

initialRoute={{id: 'LoginScreen'}}

renderScene={this.navigatorRenderScene}/>

In navigatorRenderScene() method, I have declared the different routes in app.

then how to add initial root as DashboardScreen after login success.

网友答案:

You can use a state to declare a initial route.

if() //check if user if connected
        this.state.initial = {id: 'DashboardScreen'}
else
        this.state.initial = {id: 'LoginScreen'}

and in your Navigator:

<Navigator
        style={styles.container}
        initialRoute={this.state.initial}
        renderScene={this.navigatorRenderScene}/>
分享给朋友:
您可能感兴趣的文章:
随机阅读: