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

Fix for React/Node #167

Closed
jrock17 opened this issue Aug 2, 2017 · 4 comments
Closed

Fix for React/Node #167

jrock17 opened this issue Aug 2, 2017 · 4 comments

Comments

@jrock17
Copy link

jrock17 commented Aug 2, 2017

Is there a way to use this (and packery) in a React/NodeJS environment?

When I try to require, I get a bunch of errors around 'window is not defined'.

Thanks!

@desandro
Copy link
Owner

desandro commented Aug 4, 2017

Hello! Thanks for reporting this issue.

Draggabilly was designed for the browser. See #101 (comment)

I feel like the conditional should be higher up — this module shouldn't be loaded in the first place

That said, I'm open to improving support for server-side rendering, so these errors don't get in the way of your development. Could you help me understand what you're looking for?

@jrock17
Copy link
Author

jrock17 commented Aug 6, 2017

I'm not sure what the fix is. But the error I get is:
packery.js:481
})( window );
^
ReferenceError: window is not defined

I've tried some node/react ports but they don't seem to work. Would be great if it was compatible.

@yaodingyd
Copy link

@jrock17 you can add the following in your entry point:

if (typeof window === 'undefined') {
    global.window = global
}

This is more of a hack and it should work for your situation.

desandro added a commit that referenced this issue Dec 29, 2021
@desandro
Copy link
Owner

Draggabilly v3 has been released that checks for window and falls back to this.

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

3 participants