react-native-router-flux如何用react-native-drawer打开场景?

时间:2017-05-23 12:09:40

标签: react-native react-native-router-flux react-native-drawer

我尝试使用 react-native-router-flux

在我的应用中使用 react-native-drawer https://github.com/root-two/react-native-drawer

根据documentation我已将带有抽屉的场景添加到路由器:

import NavigationDrawer from './scenes/NavigationDrawer';
import MetricsScene from './scenes/MetricsScene';
...
<Router>
     <Scene key="root">

         <Scene key="login"
             component={LoginScene}
             hideNavBar={true}
             initial
         />

         <Scene key="drawer" component={NavigationDrawer} open={false} >
             <Scene key="metrics" component={MetricsScene}/>
         </Scene>

     </Scene>
</Router>

在我的LoginScene中,我致电:

Actions.metrics({type: ActionConst.RESET});

按下登录按钮后,但没有发生。

有什么想法吗?提前谢谢。

1 个答案:

答案 0 :(得分:0)

你可以尝试下面的方法

添加了登录组件

import React, { Component } from 'react';
import { Router, Scene } from 'react-native-router-flux';

//Components
import loginfrom './scenes/login'; // Added the your login component
import NavigationDrawer from './scenes/NavigationDrawer';
import MetricsScene from './scenes/MetricsScene';


const App = () => {
  return (
    <Router>
        <Scene key="login" component={LoginScene}  hideNavBar={true} duration={0} />
        <Scene key="drawer" component={NavigationDrawer} open={false} >
             <Scene key="metrics" component={MetricsScene}/>
         </Scene>
    </Router>
  );
}

export default App;