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

时间:2018-02-28 07:58:53

标签: javascript reactjs react-native react-navigation

所以就是这种情况,我有登录页面,当状态是登录前它将呈现登录按钮但是当登录后它将呈现抽屉页面但问题抽象页面不是一个组件对吗?因为你从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不是反应组件而是抽绳器。

1 个答案:

答案 0 :(得分:0)

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

使用如下返回:

return (<DrawerRoute/>);