Skip to content
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

window object not available on server rendering #63

Closed
jyj1993126 opened this issue Jan 12, 2016 · 4 comments
Closed

window object not available on server rendering #63

jyj1993126 opened this issue Jan 12, 2016 · 4 comments

Comments

@jyj1993126
Copy link

Hi all ,
while I am using the UI Library : antd , I've got an error like this:

ReferenceError: window is not defined
    at Object.<anonymous> (/Applications/MAMP/htdocs/react/react-static-boilerplate/node_modules/antd/node_modules/velocity-animate/velocity.js:403:4)
    at Module._compile (module.js:425:26)
    at Module._extensions..js (module.js:432:10)
    at Object.require.extensions.(anonymous function) [as .js] (/Applications/MAMP/htdocs/react/react-static-boilerplate/node_modules/babel-core/lib/api/register/node.js:214:7)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Applications/MAMP/htdocs/react/react-static-boilerplate/node_modules/antd/node_modules/rc-queue-anim/lib/QueueAnim.js:23:24)
    at Module._compile (module.js:425:26)

I think it is because we rendered the elements on server and there is no window object without a window.
Am I right ? How could I fix it ?
Please help me .
Thanks

@dsernst
Copy link

dsernst commented Jan 12, 2016

Wrap the problematic components with:

import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment';

if (canUseDOM) {
  <ClientOnlyComponent />
}

like in this example.

@dsernst
Copy link

dsernst commented Jan 22, 2016

@jyj1993126 fixed?

@perminder-klair
Copy link

@dsernst does fixes issue for me! many thanks!

@koistya
Copy link
Member

koistya commented Jul 4, 2016

This issues should be gone now if you're using the latest version of RSB from master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants