question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

global.performance.now is not a function

See original GitHub issue

Description

I run into the following type error when trying to attach a chrome debugger to the iOS simulator or physical device. global.performance.now is not a function

Screenshot 2021-12-17 at 12 48 34

Expected behavior

The type error should not appear and chrome debugging should be possible

Actual behavior & steps to reproduce

So far I was not able to reproduce it in a minimal code example (still working on it), but I can fix it in my app by commenting out every import of react-native-reanimated

Snack or minimal code example

tbd soon

Package versions

  • React Native: 0.66.0 (also seen on 0.66.4)
  • React Native Reanimated: 2.3.0
  • NodeJS: v16.13.1
  • Xcode: 13.1
  • Chrome, Brave, react-native debugger with latest versions

Affected platforms

  • Android
  • iOS
  • Web

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
arealmaascommented, Jan 9, 2022

Is this going to be released in a version soon?

3reactions
kennethlynnecommented, Jan 14, 2022

If you’re on 2.3.1 just use https://www.npmjs.com/package/patch-package

patches/react-native-reanimated+2.3.1.patch

diff --git a/node_modules/react-native-reanimated/src/reanimated2/core.ts b/node_modules/react-native-reanimated/src/reanimated2/core.ts
index 2e0c38a..e9ae28f 100644
--- a/node_modules/react-native-reanimated/src/reanimated2/core.ts
+++ b/node_modules/react-native-reanimated/src/reanimated2/core.ts
@@ -383,9 +383,11 @@ if (!NativeReanimatedModule.useOnlyV1) {
         info: runOnJS(capturableConsole.info),
       };
       _setGlobalConsole(console);
-      global.performance = {
-        now: global._chronoNow,
-      };
+      if (global.performance == null) {
+        global.performance = {
+          now: global._chronoNow,
+        };
+      }
     })();
   }
 }

Read more comments on GitHub >

github_iconTop Results From Across the Web

global.performance.now is not a function in react native ...
Unable to find any solution to this query. TypeError: global.performance.now is not a function at node_modules/expo/build/ ...
Read more >
global.performance.now is not a function in react native # ...
Description. When launching an app that uses reanimated and open the Chrome debugger on iOS, we get the following error:.
Read more >
TypeError: global.performance.now is not a function
TypeError: global.performance.now is not a function ; 1. make change to this file: node_modules/react-native-reanimated/src/reanimated2/core.ts Line 386, remove ...
Read more >
performance.now() - Web APIs - MDN Web Docs
The performance.now() method returns a DOMHighResTimeStamp, measured in milliseconds.
Read more >
How to solve the issue that arise while using performance. ...
Generally, the best way to check the performance of the functions in JavaScript is the built-in performance.now() method.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found