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

Does not work on Next.js SSR/CSR #72

Open
kumarabhirup opened this issue Aug 17, 2022 · 8 comments
Open

Does not work on Next.js SSR/CSR #72

kumarabhirup opened this issue Aug 17, 2022 · 8 comments
Assignees

Comments

@kumarabhirup
Copy link

kumarabhirup commented Aug 17, 2022

I am trying to use this on Next.js v12 I get the self is not defined error.

To fix that, I tried Next.js Dynamic, but the error persists in other ways.

const contextMenus = dynamic(() => import("cytoscape-context-menus"), {
  ssr: false,
});

Cytoscape.use(contextMenus); //-> throws error etc.apply is undefined

I also tried this,

dynamic(() => {
   return import("cytoscape-context-menus").then((x) => {
     Cytoscape.use(x); // simply doesn't work (cy.contextMenus doesn't exist)
     return x;
   })
});

Am I missing something? Thank you!

@hasanbalci
Copy link
Contributor

hasanbalci commented Aug 18, 2022

@kumarabhirup I'm not experienced with Next.js, but you are probably trying to use extension in server side with Node.js, right? Can you confirm this? If this is the case, I think I know the reason for self is not defined error and I can fix it.

@kumarabhirup
Copy link
Author

kumarabhirup commented Aug 18, 2022 via email

@hasanbalci
Copy link
Contributor

hasanbalci commented Aug 18, 2022

@kumarabhirup I made a commit in unstable branch. Generally, self is not defined error comes in Node.js, so I changed it to be this instead of self and this change generally solves the problem. Can you try unstable branch and check whether your problem is solved or not?

@kumarabhirup
Copy link
Author

@hasanbalci I am checking this out, and will let you know asap!

@dkgitcode
Copy link

@hasanbalci @kumarabhirup and I just tried using the unstable branch and we are still getting the same etc.apply bug. After not dynamically importing we also get a ReferenceError: HTMLButtonElement is not defined. Any thoughts on how to fix? Perhaps we are not installing the unstable branch correctly? We npm installed the unstable git branch and ran npm run build inside the node module.

@ajmeese7
Copy link

Could we get this revisited? I'm having the same error with Svelte currently, I would definitely like to see this resolved so I can integrate this awesome module.

I also have SSR enabled, the Cytoscape instance isn't created until after the component is mounted, but the import statements are above that code, so my issue is likely the same as the one described above with Next.js.

@unidesigner
Copy link

unidesigner commented Jan 3, 2023

Any update on this? Has anybody figured out a workaround?

@jado66
Copy link

jado66 commented Jan 19, 2023

I would like this as well

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

6 participants