我一直在尝试使用 React Native 创建一个带有抽屉的移动应用程序。
我按照文件所说的做了所有事情。
一切正常,除了当我尝试使用时;
import { createDrawerNavigator } from "@react-navigation/drawer";
const Drawer = createDrawerNavigator();
反应导航抽屉让我的应用程序变得疯狂,我一直在网上搜索来修复它,但文学上没有答案。
完全错误:
Error: Exception in HostFunction: expected 0 arguments, got 1, js engine: hermes
ERROR Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes
版本:
"@react-navigation/drawer": "^6.6.7",
"react-native-gesture-handler": "^2.15.0",
"react-native-reanimated": "^3.7.0"
将“react-native-reanimated/plugin 插件”添加到“babel.config.js”中。
模块.导出= {
presets: [
... // don't add it here :)
],
plugins: [
...
'react-native-reanimated/plugin',
],
};
有关更多详细信息,请参阅:https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/
之后,您需要通过运行“yarn start --rest-cache”来重新启动 Metro 服务器,然后重新运行您的应用程序。