【问题标题】:TypeError: global.performance.now is not a function in react nativeTypeError: global.performance.now 不是 react native 中的函数
【发布时间】:2022-01-03 10:25:49
【问题描述】:

error


找不到此查询的任何解决方案。

TypeError: global.performance.now is not a function
at node_modules/expo/build/logs/LogSerialization.js:156:14 in _captureConsoleStackTrace
at node_modules/expo/build/logs/LogSerialization.js:41:26 in serializeLogDataAsync
- ... 9 more stack frames from framework internals


【问题讨论】:

  • 请分享您的代码以获取更多信息

标签: reactjs react-native react-redux


【解决方案1】:

更改此文件:node_modules/react-native-reanimated/src/reanimated2/core.ts 第 386 行,删除:

global.performance = {
 now: global._chronoNow,

};

然后添加这个:

if(global.performance == null) {
    global.performance = {
      now: global._chronoNow,
    };
  }

【讨论】:

  • 这是一个临时解决方案。请提供一个永久的解决方案。因为每次安装节点模块后都会更改。
  • 如果您不想降级并希望保留您的 node_modules 补丁:npx patch-package react-native-reanimated
【解决方案2】:

这是复活的问题,修复将很快发布https://github.com/software-mansion/react-native-reanimated/commit/aef72c0875b559eecb7e10abaf00e49186d7ae55,目前,我建议将其降级到 2.2.4

【讨论】:

  • "react-native-reanimated": "^2.3.1" 它也将出现在最新版本的 reanimated 中
【解决方案3】:

如果您正在使用 expo 应用程序,请尝试重新安装最新的 expo 应用程序或将设备连接到计算机并运行expo start 命令,然后点击(a or i) 以在您的设备上自动安装兼容版本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-08-23
    • 2017-07-27
    • 1970-01-01
    • 2020-10-28
    • 2021-08-12
    • 1970-01-01
    • 2020-12-25
    相关资源
    最近更新 更多