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

ReferenceError: window is not defined #40

Open
MilanObrenovic opened this issue Apr 2, 2023 · 1 comment
Open

ReferenceError: window is not defined #40

MilanObrenovic opened this issue Apr 2, 2023 · 1 comment

Comments

@MilanObrenovic
Copy link

Describe the bug
I installed this library, latest version as of now (1.41.5), but getting ReferenceError: window is not defined error.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/step-15-trackball-controls-fixed-xdrgv?from-embed=&file=/src/initializeScene.js
  2. This tutorial was originally written by https://dev.to/pahund/adding-trackball-controls-to-a-three-js-scene-with-sprites-48hp
  3. Use the same code example from codesandbox website example into the existing nextjs project.
  4. Run the project
  5. See error

Expected behavior
A mind map graph to be visible just like in the example

Screenshots
image

Desktop (please complete the following information):

  • OS: Mac Ventura 13.3
  • Browser: Chrome
  • Version: 111.0.5563.146
@MilanObrenovic
Copy link
Author

I think i found a solution. for anyone having similar problems:

TLDR: https://stackoverflow.com/questions/58622615/how-to-import-trackballcontrols-from-three-js-module-using-react

Long version: works fine in normal react app but not nextjs app because nextjs is SSR. In nextjs you need to dynamically import this three-forcegraph library (as well as some others if needed) and then use it from inside the useEffect()

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

1 participant