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

[2.2.0] window is not defined on server-side rendering #645

Closed
GGAlanSmithee opened this issue Feb 7, 2017 · 8 comments · Fixed by #1193
Closed

[2.2.0] window is not defined on server-side rendering #645

GGAlanSmithee opened this issue Feb 7, 2017 · 8 comments · Fixed by #1193
Assignees
Labels

Comments

@GGAlanSmithee
Copy link

Just updated to v2.2.0 and am now getting window is not defined when doing server-side rendering.

stack

window is not defined
ReferenceError: window is not defined 
at HTML5Backend.get (/home/node/node_modules/react-dnd-html5-backend/lib/HTML5Backend.js:615:53) 
at HTML5Backend.setup (/home/node/node_modules/react-dnd-html5-backend/lib/HTML5Backend.js:71:22) 
at DragDropManager.handleRefCountChange (/home/node/node_modules/dnd-core/lib/DragDropManager.js:52:22) 
at Object.dispatch (/home/node/node_modules/redux/lib/createStore.js:186:19) 
at HandlerRegistry.addSource (/home/node/node_modules/dnd-core/lib/HandlerRegistry.js:104:18) 
at registerSource (/home/node/node_modules/react-dnd/lib/registerSource.js:9:27) 
at DragDropContainer.receiveType (/home/node/node_modules/react-dnd/lib/decorateHandler.js:146:32) 
at DragDropContainer.receiveProps (/home/node/node_modules/react-dnd/lib/decorateHandler.js:135:14) 
at new DragDropContainer (/home/node/node_modules/react-dnd/lib/decorateHandler.js:102:13) 
at /home/node/node_modules/react-dom/lib/ReactCompositeComponent.js:295:18

in the realeases page I can see there were some updates which might affect ssr, namely

Add DragContextProvider class, use updated dnd-core with support for injectable global context.

But the docs does not mention anything about it (as far as I can see), so not quite sure how to apply the new changes, if that's what's required for ssr to work.

@GGAlanSmithee
Copy link
Author

Seems like I might have spoken too soon, because the error persists when I downgrade to earlier versions.

I really thought it was related to your latest realease because this was the first deploy I made since react-dnd was updated (not locked version in stage environment) and the stack trace pointed to it. Will investigate, sorry for the noise.

@nashaddams
Copy link

Same problem on my side. Also investigating.

@GGAlanSmithee
Copy link
Author

@ninoperin ok, then I guess it's better to re-open this until something is confirmed.

@darthtrevino
Copy link
Member

I see, the previous version was using a typeof window to check to see if the window was valid. I'll have something up shortly.

@darthtrevino darthtrevino self-assigned this Feb 7, 2017
darthtrevino added a commit that referenced this issue Feb 7, 2017
darthtrevino added a commit that referenced this issue Feb 7, 2017
#646)

* (#645) - Use 'typeof window' to check for window existence in HTML5 Backend

* (#645) - Add tests to the HTML5Backend class to check window injection cases

* (#645) - Patch Version Bump
@darthtrevino
Copy link
Member

@GGAlanSmithee @ninoperin Can you try react-dnd-html5-backend@2.2.1?

@nashaddams
Copy link

Works. Thanks for that quick fix!

@GGAlanSmithee
Copy link
Author

Yes, thank you very much @darthtrevino

@m4rk3r
Copy link

m4rk3r commented Nov 30, 2018

It looks like this issue has resurfaced in v7.0.0, perhaps: 572955b#diff-5177492c6e40a1abfcb33fc0dc4bc3c3R20

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

Successfully merging a pull request may close this issue.

4 participants