-
Notifications
You must be signed in to change notification settings - Fork 18
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
SSR client side error "window is not defined" #35
Comments
In Next.js this can be solved with dynamic imports
|
This issue seems to be from the "style-loader" module. Which uses window. functions without checking if the window is set. The general suggestion is to use isomorphic-style-loader. I've tried doing this but I did not manage to get the css to actually load (so was a pointless endeavour). Perhaps someone who understands webpack better than me can get this to work correctly. The workaround for people using normal React with custom SSR is to have something like:
This should prevent the component from being rendered on the serverside, but will probably result in the button to be missing on initial render, so not ideal especially for people with slower machines. Fragment here is React.Fragment, I think you can just use null as well. |
I try to use this module with SSR React + Express inside a Form with Bootstrap-react module, but it failed with ReferenceError: window is not defined from bootstrap-switch-button-react.js:1:9869
The text was updated successfully, but these errors were encountered: