Closed tinybitsofcode closed 2 years ago
Yep, been there. Next automatically supports SSR, and isDOM ( used here import {isNode as isDOM} from './utils/typeUtils';
) breaks SSR for React Inspector, try code splitting to avoid the SSR phase:
let ReactInspector = null;
//inside a useEffect, or useSWR hook, or via next/dynamic
ReactInspector = import('react-inspector');
Describe the bug
Trying to integrate the Inspector with the latest NextJS, will prompt the
ReferenceError: window is not defined
error, with minimal configuration of react-inspector.Steps to reproduce the behavior
npx create-next-app@latest
)react-inspector
(usingnpm install react-inspector
)pages/index.js
file, type the<Inspector data={[]} />
somewhere in the body of the file (in the React component > render function)npm run dev
)http://localhost:3000
and the error should be promptedExpected behavior
The Inspector should correctly show the data passed through, and allow the application to start.
Screenshots and/or logs
Environment
Additional context
Below is the full stacktrace of the error.