-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When building I get WebpackError: ReferenceError: window is not defined #10749
Comments
Happy new year @ergunpp Apologies that you’re seeing this. The build is breaking because This works during The simple fix for this is to only access |
In context of the example above, change
to
(you're already setting it in |
Thank you. |
Ah, right. So with server side rendering, you’ll have to default to one of the cases. Or you could use CSS media queries to set visibility based on viewport. |
Closing this for now but please feel free to reopen if there’s anything else @ergunpp |
Is it possible to make a media query in the constructor and then define the default? |
@ergunpp Unfortunately that won't work because the constructor code is run during |
I have finally finished a project that runs fine on development mode.
However when trying to build, I get
I get the error at several locations as stated below:
`WebpackError: ReferenceError: window is not defined
index.js:14 new Navi
lib/src/components/Navi/index.js:14:24
bootstrap:25 a.render
lib/webpack/bootstrap:25:1
bootstrap:24 a.read
lib/webpack/bootstrap:24:1
bootstrap:36 renderToString
lib/webpack/bootstrap:36:1
static-entry.js:190 Object../.cache/static-entry.js.webpack_exports.default
lib/.cache/static-entry.js:190:18
bootstrap:24 e
lib/webpack/bootstrap:24:1
gatsby-browser-entry.js:1 Promise._resolveFromExecutor
lib/.cache/gatsby-browser-entry.js:1:1
bootstrap:68 new Promise
lib/webpack/bootstrap:68:1
bootstrap:5 tryCatcher
lib/webpack/bootstrap:5:1
bootstrap:50 MappingPromiseArray._promiseFulfilled
lib/webpack/bootstrap:50:1
api-runner-ssr.js:3 MappingPromiseArray.PromiseArray._iterate
lib/.cache/api-runner-ssr.js:3:16
bootstrap:67 MappingPromiseArray.init
lib/webpack/bootstrap:67:1
`
The main code I am using windows is in the Navi Component:
`
I seems that I need to change the complete structure of bootstrap media queries along with the code above. Is there an easy and quick way to do this?
How should the code be changed?
Appreciate your help, thanks a lot.
The text was updated successfully, but these errors were encountered: