Server Error
ReferenceError: window is not defined
Can't surpass this error...
code:https://gist.github.com/Jishnu-02/b90cab1c887ac8b64122ffbb29844313
Server Error
ReferenceError: window is not defined
Can't surpass this error...
code:https://gist.github.com/Jishnu-02/b90cab1c887ac8b64122ffbb29844313
For further actions, you may consider blocking this person and/or reporting abuse
Hitesh Chauhan -
Teo Nordic -
Angesh Singh -
Guillaume Sere -
Top comments (6)
I don't get what your point is, are you asking for help?
It's normal to get an error,
window
is not defined on the server. Remember that Next runs your code on the server when building the HTML file.Initialise your state to 0 and update it to
window.innerWidth
in useEffect.can u show me how to do it?
Something like that:
Thank You.
You are using next.js so you can use Window only client side, which means you can use It only on useEffect hook.
Window Is not defined on serverside
can u show me how to do it?