【问题标题】:Reanimated 2 failed to create a worklet, maybe you forgot to add Reanimated's babel plugin?, js engine: hermesReanimated 2创建worklet失败,可能你忘了添加Reanimated的babel插件?,js引擎:hermes
【发布时间】:2022-01-18 10:49:38
【问题描述】:

我遇到了 React-native-Reanimated 的问题。
收到“Reanimated 2 未能创建worklet,可能你忘了添加Reanimated 的babel 插件?,js 引擎:hermes” 但是我已经关注了https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation

这是我的复活版:

"react-native-reanimated": "^2.3.0"

这是我的 babel.config.js

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: ['react-native-reanimated/plugin'],
};

请帮我解决这个问题。非常感谢

【问题讨论】:

标签: javascript react-native


【解决方案1】:

如果您使用的是 expo,而不是使用 npm 安装:

expo install react-native-reanimated

在 babel.config.js 中像这样使用它:

module.exports = function(api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo'],
    plugins: ['react-native-reanimated/plugin'],
  };
};

【讨论】:

    猜你喜欢
    • 2021-07-11
    • 2021-06-19
    • 2021-11-27
    • 2021-11-25
    • 2022-01-09
    • 2023-01-29
    • 2021-01-05
    • 2022-11-17
    • 2023-02-11
    相关资源
    最近更新 更多