Reanimated 2 未能创建 worklet — 也许您忘记添加 Reanimated 的 babel 插件?
Reanimated 2 failed to create a worklet — Maybe You Forgot to Add Reanimated’s babel Plugin?
我已尽我所能解决此错误。我尝试卸载 reanimated-bottom-sheet 和 react-native-reanimated 并重新安装它们。清除缓存。我不知道要编辑的 babel.config.js 文件。我知道错误来自下面这个确切的导入。
import BottomSheet from 'reanimated-bottom-sheet';
我还链接了一个存储库以重现我的确切问题 here。我添加了我的 node_modules 以防万一,我不确定它是否会帮助别人看到我做错了什么。
您需要在项目的根目录(靠近 package.json)中添加 babel.config.js
,并具有以下上下文(或者直接从 https://github.com/software-mansion-labs/reanimated-2-playground 中获取):
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
'react-native-reanimated/plugin',
],
};
检查重新激活的文档https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/
我将 'react-native-reanimated/plugin' 添加到 babel.config.js - 但我也有 .babelrc...只保留其中一个...
__reanimatedWorkletInit
函数和 __worklet
属性 已在 react-native-reanimated@2.7.0
.
中删除
检查动画版本 https://github.com/software-mansion/react-native-reanimated/releases。
就我而言,我刚刚降级到 react-native-reanimated@2.6.0
并且效果很好
我已尽我所能解决此错误。我尝试卸载 reanimated-bottom-sheet 和 react-native-reanimated 并重新安装它们。清除缓存。我不知道要编辑的 babel.config.js 文件。我知道错误来自下面这个确切的导入。
import BottomSheet from 'reanimated-bottom-sheet';
我还链接了一个存储库以重现我的确切问题 here。我添加了我的 node_modules 以防万一,我不确定它是否会帮助别人看到我做错了什么。
您需要在项目的根目录(靠近 package.json)中添加 babel.config.js
,并具有以下上下文(或者直接从 https://github.com/software-mansion-labs/reanimated-2-playground 中获取):
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
'react-native-reanimated/plugin',
],
};
检查重新激活的文档https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/
我将 'react-native-reanimated/plugin' 添加到 babel.config.js - 但我也有 .babelrc...只保留其中一个...
__reanimatedWorkletInit
函数和 __worklet
属性 已在 react-native-reanimated@2.7.0
.
检查动画版本 https://github.com/software-mansion/react-native-reanimated/releases。
就我而言,我刚刚降级到 react-native-reanimated@2.6.0
并且效果很好