无法呈现抽屉页面反应原生?

问题描述 投票:0回答:1

所以这就是这种情况,我有登录页面,当状态是登录前它将呈现登录按钮但是当登录后它将呈现抽屉页面,但问题抽象页面不是一个组件对吗?因为你从drawernavigator得到抽屉页面,所以我该怎么办?这是我的代码如下

这是渲染案例

   import DrawerRoute from './DrawerRoute';
 _renderContent() {

    switch(this.state.displayType) {

      case 'before_login' :
        return <TouchableOpacity style={styles.button}
          onPress={(this._showADLogin.bind(this))}>
          <Text style={{color : 'black'}}>Login Sekarang</Text>
        </TouchableOpacity>
      case 'login' :
        // In fact we care if it successfully redirect to the URI, because
        // we alread have the access_token after successfully logged in.
        // set `hideAfterLogin` to `true` so that it won't display an error page.
        return [
          <ADLoginView
            key="webview"
            hideAfterLogin={true}
            style={{flex :1}}
            needLogout={this.state.shouldLogout}
            context={ADContext}
            onURLChange={this._onURLChange.bind(this)}
            onSuccess={this._onLoginSuccess.bind(this)}/>]
      case 'after_login' :

      return [
          <DrawerRoute/>
      ]

这是我的DrawerRouter

   import React, { Component } from 'react';
    import FormCuti from './FormCuti';
    import FormLogin from './FormLogin';
    import DrawerMenu from './DrawerMenu';
    import NavigationReplace from './NavigationReplace';
    import {StackNavigator, DrawerNavigator  } from 'react-navigation';



 const MainDrawer = StackNavigator ({
    FormLogin : {screen : FormLogin},
    FormCuti : {screen : FormCuti},
    NavigationReplace : {screen : NavigationReplace}
   // ScreenCuti : {screen : ScreenCuti}
 });
 const Drawer = DrawerNavigator(
  {
    Main : {screen : MainDrawer}
  },
  {
    contentComponent: DrawerMenu,
    drawerWidth: 200
  }
);


export default Drawer;

任何人都可以在这里给我灵感,因为DrawerRoute不是反应组件而是drawernavigator。

javascript reactjs react-native react-navigation
1个回答
0
投票

必须使用带有“()”的返回组件。在您的代码中,使用“()”更改所有“[]”。

使用如下返回:

return (<DrawerRoute/>);
© www.soinside.com 2019 - 2024. All rights reserved.