我正在尝试设置一个 react native 导航抽屉,我有一个按钮可以正确切换抽屉,尽管我正在尝试设置滑动功能来打开抽屉,但这根本不起作用。我的drawer.js文件如下
import React from 'react';
import { createDrawerNavigator } from '@react-navigation/drawer';
import { NavigationContainer } from '@react-navigation/native';
import HomeStack from './homeStack';
import AboutStack from './aboutStack';
const Drawer = createDrawerNavigator();
export const AppNavigator = () => (
<NavigationContainer>
<Drawer.Navigator initialRouteName='Home'>
<Drawer.Screen
name='Home'
component={HomeStack}
/>
<Drawer.Screen
name='About'
component={AboutStack}
/>
</Drawer.Navigator>
</NavigationContainer>
);
export default AppNavigator;
它像这样导入到我的 App.js
import React from 'react';
import Navigator from './routes/drawer';
export default function App() {
return (
<Navigator />
)
}
我已经尝试过 this post 中的建议,但没有成功。
我正在运行 react native 0.63、react native navigation 5.9、react native navigation drawer 5.12.3 和 react native 手势处理程序 1.10.0
这里参考的是我的 index.js 文件,其中包含前面提到的帖子中的更新
/**
* @format
*/
import { AppRegistry } from 'react-native';
import App from './App';
import { name as appName } from './app.json';
import { gestureHandlerRootHOC } from 'react-native-gesture-handler'
AppRegistry.registerComponent(appName, () => gestureHandlerRootHOC(App));