-
Notifications
You must be signed in to change notification settings - Fork 760
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
Builds fail for components requiring window
#16
Comments
Since react-static builds static versions of your site, most times you'll need to make sure the if (typeof window !== 'undefined') {
// browser-only code
} |
Hi guys ! Is React static can be used in other context than browser ?
this exemple works, but when you are using multiple front libraries it quickly become a mess ^^ What you think ? |
Hello, I'm also having troubles with window variable. When I run
But when I run |
You must write node safe code. Using window without a document check will error in the build stage because there is no DOM. https://react-static.js.org/docs/concepts#writing-universal-node-safe-code |
Hi there!
Really great work on this, very nice alternative to Next + Gatsby and very slick. I've been getting errors on my build, I have 2 components that need the browsers window object and they crash the build process, I've tried a few different thinks like
ErrorBoundary
etc. My project runs just fine in the dev environment (minus my font but ill get to that later).Here is the error:
ReferenceError: window is not defined
Here is the Repo
Anyway, thanks for this killer project, deff gonna use this for some more things in the future.
The text was updated successfully, but these errors were encountered: