In my Next.js app I can't seem to access window
:
Unhandled Rejection (ReferenceError): window is not defined
componentWillMount() {
console.log('window.innerHeight', window.innerHeight);
}
Another solution is by using process.browser
to just execute your command during rendering on the client side only.
if (process.browser) {
// Client-side-only code
}