-
Notifications
You must be signed in to change notification settings - Fork 95
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
Chart getting duplicated for every useEffect call in react app #100
Comments
@vasturiano Please let me know, how to fix this one |
@jeyk333 thanks for reaching out. This seems to be more of a question around React rather than this Sunburst component. You can also use react-kapsule as it does all the wrapping for you out of the box. |
Ok, let me check with react-kapsule library |
@vasturiano I have tried using React-kapsule. But, the similar issue occurs here too.
Whenever, I tried to interact with the chart, this console error occurs and chart is not zooming |
@jeyk would you mind making a reproducing simple example on https://codesandbox.io/ ? |
sure |
In React v18 the duplicate is expected when using Strict Mode in development. It won't show up in production or if you remove Strict Mode. Replace: |
For those of us who do not have the option of removing StrictMode, there is a better solution. Please see this issue explanation for more on why this happens and how to implement specifically in a React app. You do not need to use Kapsule (and I would recommend against using it) Essentially what @jeyk333 needs to do here is add a cleanup function to his useEffect of
and that should do the trick. @vasturiano This issue should probably now be marked as closed. |
In my react, I am calling the chart method inside useEffect with data and also passing the data variable in the dependency array. Initially, its rendering properly. But, whenever, the data get updated, instead of the updating the chart, its creating new chart on every useEffect call. How can I solve this chart duplicating and instead of it, I need the chart to get updated.
The text was updated successfully, but these errors were encountered: