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

My code broke when I started using useRef in the ForceGraph component in Next.js 15 #551

Open
cruzmedien opened this issue Nov 7, 2024 · 6 comments

Comments

@cruzmedien
Copy link

cruzmedien commented Nov 7, 2024

Hello, I’m using the ForceGraph in a Next.js 15 project, but when I use a ref in the ForceGraph, I receive the error below. It seems like it’s re-rendering the reference infinitely or something similar. All my functionalities work, even the camera, but I get this infinite re-rendering in the console.

Here is my Code:
image

I would appreciate the help.

Originally posted by @cruzmedien in #324 (comment)

@cruzmedien cruzmedien changed the title Hello, I’m trying to get the camera behavior to work in my project, but it doesn’t work. I’m using Next.js 15 and followed all the steps, including isolating the dynamic wrapper, but I still get this error: My code broke when I started using useRef in the ForceGraph component in Next.js 15 Nov 7, 2024
@vasturiano
Copy link
Owner

@cruzmedien this is likely related to this from a different library: vasturiano/react-kapsule#14

However, if this is next.js specific, it's not clear what changed in next.js 15 that makes the behavior of useState differ from previous versions. Perhaps someone with more insight can comment on this so we can apply the correct fix.

@cruzmedien
Copy link
Author

I had to downgrade to Next.js version 14.2.17. With this version, everything works. It would be helpful to identify the issue with version 15.

@vasturiano
Copy link
Owner

@cruzmedien are you able to do a simple reproducing example on codesandbox so we use it as a base to debug this further? That platform allows you to setup an app with next.js 15, so it should be reproducible.

@cruzmedien
Copy link
Author

@vasturiano Hello, I created a small example here: codesandbox
You can see the error in the console. I hope this helps in finding a solution.

@vasturiano
Copy link
Owner

@cruzmedien thanks for making that example.

I've applied a fix for this. If you upgrade to the latest version of the module (react-force-graph-3d: 1.24.6) you shouldn't experience the issue any more.

@cruzmedien
Copy link
Author

Thank you very much. Now it works perfectly. I really appreciate the great support.

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

2 participants