-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Nextjs Window not defined #17
Comments
I had to do this to work hmm
const grayStyle = { backgroundColor: "#eee" }; |
Presumably there is a reference to window somewhere before componentDidMount(). I haven't had much exposure to next.js so will try to repro the setup. |
I've pinpointed this down to the bundling and specifically the bundling of SCSS which breaks the components when doing SSR (it's currently using style-loader re this issue webpack-contrib/style-loader#109). I am revising the bundling to use rollup instead of webpack and also revising the way the styling is applied to the components which should fix this issue. Hopefully this will be ready for release in the next version. |
@zifahm I've released version 0.1.14 now which has some changes into how the library is bundled and more specifically how styling is added to the page which should allow you to use the components without your workaround above. Let me know if this works for you. It does however exhibit the standard late style load behaviour when a page is first displayed due to the styling only being injected on to the page when the javascript has been fully loaded. Due to the benefits of having a layout library working with SSR I am working on a server-side specific bundle which in intended to be used with SSR specific applications. You can currently try using this by importing 'react-spaces/dist/server' instead of 'react-spaces' and also importing 'react-spaces/dist/server.css' by using @zeit/next-css. It's currently experimental though and has some placement problems at the moment but you can check out a test app here - https://github.com/aeagle/react-spaces/tree/master/nextjsdemo |
@aeagle sure thanks. Ill let you know if i am incurring any problems. |
I'll close this now. I can reopen if you are still having problems. |
The bug
I am getting a window is not defined error while using it on nextjs.
To Reproduce
Codesandbox demo form the docs in nextjs with apollo
Expected behavior
Run with no error.
Screenshots
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: