Closed feyzullahyildiz closed 10 months ago
@feyzullahyildiz Thank you for raising this issue. I agree that the SDK should expose some sort of destroy
method to assist with cleaning up the DOM nodes created inside the divRef
element, we will look into adding this functionality to the SDK.
In the interim I have put together this CodeSandbox example for you, to demonstrate how to manually do this cleanup yourself inside the function returned by useLayoutEffect
.
I also noticed a small error in your usage of useRef
in the example code provided. You should not be manipulating the DOM directly by creating an element as the initial value to useRef
like you are below:
const divRef = useRef(document.createElement('div'));
All this is doing is creating an Element
which is not being used by the document, as the reference is later assigned the <div className='chart' />
node. Instead, divRef
should be initialised as null
:
const divRef = useRef(null);
Closing this as it's a feature request rather than a bug. Thank you @matt-d-rat for providing a workaround. I've posted the idea to the MDB Charts Feature Request page to get more visibility and upvotes - you can find it here.
Describe the bug destroyChart and destroyDashboard functions does not exists. How can I destroy these charts.