Skip to content

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

@sritMishra

Description

@sritMishra

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 !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions