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 server side rendering #16

Merged
merged 1 commit into from
Jan 17, 2018
Merged

fix for server side rendering #16

merged 1 commit into from
Jan 17, 2018

Conversation

TrejGun
Copy link

@TrejGun TrejGun commented Nov 20, 2016

I'm using this package via react-art in hybrid react application.
so when i'm trying to render my code on the server side it results in error

~/node_modules/art/modes/fast-noSideEffects.js:2
    var canvas = document.createElement('canvas');
                 ^

ReferenceError: document is not defined
    at hasCanvas (~/node_modules/art/modes/fast-noSideEffects.js:2:18)
    at Object.<anonymous> (~/node_modules/art/modes/fast-noSideEffects.js:6:5)
    at Module._compile (module.js:573:32)
    at Module._extensions..js (module.js:582:10)
    at Object.require.extensions.(anonymous function) [as .js] (~/node_modules/babel-register/lib/node.js:152:7)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12)
    at Function.Module._load (module.js:441:3)
    at Module.require (module.js:500:17)
    at require (internal/module.js:20:19)

this patch prevents a crush

@MoOx
Copy link

MoOx commented Dec 20, 2017

+1 for this

@sebmarkbage sebmarkbage merged commit 570c497 into sebmarkbage:master Jan 17, 2018
@aertmann
Copy link

@sebmarkbage thanks for merging, would you mind tagging a new version as well so it can be used down the road of dependency chains? thanks

@mkochendorfer
Copy link

@sebmarkbage Running into this same issue and really would appreciate a release being tagged with this bug fix that has already been merged.

@sebmarkbage
Copy link
Owner

tagged [email protected]

@MoOx
Copy link

MoOx commented Apr 4, 2018

(@sebmarkbage no big deal at all, but no git tag associated on github releases page, just in case your forgot)

@webnah
Copy link

webnah commented Mar 15, 2019

confired it works after change patch at other file not file abow

react-native-web-ssr-boilerplate/node_modules/art/modes/fast-noSideEffects.js

var hasCanvas = function(){

var canvas = typeof window !== 'undefined' && window.document && window.document.createElement && document.createElement('canvas');

return canvas && !!canvas.getContext;

};

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

Successfully merging this pull request may close these issues.

6 participants