-
Notifications
You must be signed in to change notification settings - Fork 14
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
ReferenceError self is not defined : Can this library work with React/Next applications ? #18
Comments
Seems like this could be relevant:
I made a branch with this change, try:
let me know if that works and I'll merge it in. |
@amandaghassaei it worked, thanks. But now there's a different error - |
@amandaghassaei Sorry I didn't see your update. I've tested the branch on a new NextJS App and I get the same error as @roygav : |
@amandaghassaei @roygav roy @indiana-dev in |
I looked into this a bit - the underlying dependencies in CCapture do not play nicely with the node environment, so unfortunately I think this is not supported right now. Eventually I'd like to redo this whole repo from the ground up and get rid of the dependency on CCapture, but not in the cards anytime soon. |
@indiana-dev @amandaghassaei I could make it work in nextjs by using dynamic import inside an async function: async function capture(canvas){
const CanvasCapture = (await import('canvas-capture')).default;
CanvasCapture.init( canvas );
....
} This way, we can make sure, that this npm package is not loaded on the server but only on client-side where window is available |
I'm trying to use this library in a Next/Vercel project however I get the following error :
which seems to indicate that the library doesn't have the
window
context. Not sure if this is more of a Next setup issue or if the library should work with these frameworks ?The text was updated successfully, but these errors were encountered: