bcrumbs / reactackle

Open-source components library built with React and Styled-Components.
https://reactackle.braincrumbs.io
MIT License
279 stars 23 forks source link

ReferenceError: window is not defined #99

Open gsoec opened 6 years ago

gsoec commented 6 years ago

This error occur on SSR

[1] /app/node_modules/reactackle-autoposition/dist/AutoPosition.js:125
[1]   parent: window,
[1]           ^
[1] 
[1] ReferenceError: window is not defined
[1]     at Object.<anonymous> (/app/node_modules/reactackle-autoposition/dist/AutoPosition.js:125:11)
[1]     at Module._compile (module.js:624:30)
[1]     at Object.Module._extensions..js (module.js:635:10)
[1]     at Module.load (module.js:545:32)
[1]     at tryModuleLoad (module.js:508:12)
[1]     at Function.Module._load (module.js:500:3)
[1]     at Module.require (module.js:568:17)
[1]     at require (internal/module.js:11:18)
[1]     at Object.<anonymous> (/app/node_modules/reactackle-autoposition/dist/index.js:8:21)
[1]     at Module._compile (module.js:624:30)
VNadygin commented 6 years ago

@gsoec Currently, Reactackle is not adapted for SSR rendering. Here is the workaround:

let AutoPosition;
if (typeof window !== "undefined") {
  SelectBox = require("reactackle-selectbox").SelectBox;
}

100

piroszhog commented 6 years ago

@gsoec You are welcome to contribute in https://github.com/bcrumbs/reactackle/issues/100. SSR is important thing, but we just haven't enough time for it now.