这是我的代码: -
import React from 'react-native';
import { Router, Drawer, Scene } from 'react-native-router-flux';
import Scene1 from '../../scenes/Scene1';
import Dashboard from '../../scenes/Dashboard';
import Images from '../../assets/images';
import styles from './Styles';
const Routes = () => (
<Router
backAndroidHandler={() => Actions.pop()}
sceneStyle={styles.sceneStyle}
>
<Scene key="root">
<Scene
key="scene1"
component={Scene1}
title="Scene 1"
navigationBarStyle={styles.navigationBarStyle}
navBarButtonColor={styles.navBarButtonColor}
titleStyle={styles.titleStyle}
initial
/>
<Drawer
hideNavBar
key="dashboard"
drawerImage={Images.menuIcon}
contentComponent={Navigation}
drawerWidth={styles.drawerWidth}
>
<Scene
key="dashboard"
component={Dashboard}
title={strings.dashboard}
navigationBarStyle={styles.navigationBarStyle}
navBarButtonColor={styles.navBarButtonColor}
titleStyle={styles.titleStyle}
renderRightButton={renderNotificationButton}
/>
</Drawer>
</Scene>
</Router>
);
export default Routes;
我正面临一个问题。每当我尝试在设备中运行应用程序时,我已经在节点模块中安装了所有npm依赖项。除抽屉组件外,所有导航工作正常;
答案 0 :(得分:3)
这是依赖项中的错误:react-navigation@1.0.0-beta.22
尝试:
npm uninstall react-navigation && npm install react-navigation@1.0.0-beta.21
该问题已为人所知:https://github.com/aksonov/react-native-router-flux/issues/2718
答案 1 :(得分:0)
尝试此命令:
rm -rf $TMPDIR/react-* $TMPDIR/react-native-packagerache-* $TMPDIR/metro-bundler-cache-*&& watchman watch-del-all && npm cache clean --force && npm i && npm start
答案 2 :(得分:0)
添加
drawerOpenRoute:&#39; DrawerOpen&#39;, drawerCloseRoute:&#39; DrawerClose&#39;, drawerToggleRoute:&#39; DrawerToggle&#39; 到DrawerNavigator解决了我的问题。试试看。
const AppDrawer = DrawerNavigator({
HomeStack: {
screen: AppStack
}
},
{
contentComponent: props => (<Sidebar {...props} />),
drawerOpenRoute: 'DrawerOpen',
drawerCloseRoute: 'DrawerClose',
drawerToggleRoute: 'DrawerToggle'
});