react-perf-devtool icon indicating copy to clipboard operation
react-perf-devtool copied to clipboard

ReferenceError: window is not defined - NextJs 10.1.3 - react-perf-devtool

Open srittam-personal opened this issue 3 years ago • 1 comments
trafficstars

Hi @nitin42 ,

I am facing an issue after installing the package to my NEXT app . I am new to NEXT and exploring this package to check on performance of the app and encountered with below error .

  1. Added the package
  2. imported the package const { registerObserver } = require('react-perf-devtool'); But can see a warning in vscode itself saying :
Could not find a declaration file for module 'react-perf-devtool'. 'xxx/node_modules/react-perf-devtool/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/react-perf-devtool` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-perf-devtool';`

Also after running my dev , i got below error in my log :

window is not defined
    at Object.<anonymous> (xxx/node_modules/react-perf-devtool/lib/devtool-hook.js:1:224)

I am using

  • Next app version : 10.1.3
  • React : 17.0.1

Let me know if you need more info on this . Thanks in advance !

srittam-personal avatar Dec 11 '21 08:12 srittam-personal

@nitin42 , Let me know once you get a chance to look at this .

srittam-personal avatar Dec 20 '21 13:12 srittam-personal