我正在尝试将
react-native-reanimated
从 v1.13.3
升级到 v2.0.1
。在安装说明中,他们说将react-native-reanimated/plugin
添加到您的babel.config.js
,如下所示:
module.exports = {
presets: [
...
],
plugins: [
...
'react-native-reanimated/plugin',
],
};
目前我的
babel.config.js
看起来像这样:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
env: {
production: {
plugins: [
'react-native-paper/babel'
],
},
}
};
如果我这样添加:
plugins: [
'react-native-paper/babel'
'react-native-reanimated/plugin'
],
我收到此错误:
Transform's input file does not exist: <project>/node_modules/react-native-reanimated/android/react-native-reanimated-65.aar. (See https://issuetracker.google.com/issues/158753935)
我应该如何添加它?
你可以尝试:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
env: {
production: {
plugins: [
'react-native-paper/babel'
],
},
},
plugins: [
'react-native-reanimated/plugin',
],
};
phuocantd 的功能有效,但是在将react-native-reanimated/plugin 添加到 babel.js 脚本后,您还需要清除缓存。我在构建项目时与 Expo 合作,可以通过首先停止 expo 服务器并运行以下命令来清除缓存:
npx expo start -c