-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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:removing forwardLegendDataRef from hook dependency #2592
base: master
Are you sure you want to change the base?
fix:removing forwardLegendDataRef from hook dependency #2592
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@ZombieChowder11, thank you for submitting a fix. I thought a ref's reference was stable, only |
I found an interesting post about this: https://epicreact.dev/why-you-shouldnt-put-refs-in-a-dependency-array/, so it seems like this change is not going to fix the problem, not passing the ref and passing the ref object (not |
The problem might be about legend data changing. |
I think you could try locally the setup you shared in the issue you created with the updated code, creating a new story for example, also log in |
Something that came to my mind was to either use a useMemo hook or a callback for the legend data changing instead of a useEffect. |
Given the simplicity of the data for the legends, maybe deeply comparing the data would be better, rather than relying on other computations which might be necessary for the chart, but won't impact the legend's data. It would probably be less prone to infinite rendering, it's really easy to end up in this situation if you don't declare the props statically/memoize them. |
Related to issue #2591 #2569
This fix should remove the infinite re-renders when creating a custom Legend for responsive pies.
forwardLegendDataRef is not needed in the dependency of the useEffect hook