DrawerNavigator 在 Expo 管理的 Reac-Native 应用程序中不起作用
发布时间:2022-07-29 07:31:22 226
相关标签: # node.js
这让我做噩梦,每当我导入createDrawerNavigator时都会出错,这是我的代码
import 'react-native-gesture-handler';
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createDrawerNavigator } from '@react-navigation/drawer';
import { StyleSheet, Text, View } from 'react-native';
import HomeScreen from './screens/HomeScreen';
export default function App() {
return (
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
我得到的错误是
Error: Requiring module "node_modules/react-native-reanimated/src/Animated.js", which threw an exception: Error: Reanimated 2 failed to create a worklet, maybe you forgot to add Reanimated's babel plugin?
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:4 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules/metro-runtime/src/polyfills/require.js:203:6 in guardedLoadModule
at http://192.168.1.75:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:null in global code
我已经编辑了 babel.config,它看起来像这样:
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo','module:metro-react-native-babel-preset'],
plugins: ['react-native-reanimated/plugin'] // reanimated plugin
};
};
所以现在我已经走到了死胡同,有什么想法吗?
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报