简体   繁体   English

我可以使用 Chart.js 在 React.js 中使用破坏图表吗?

[英]Can i use destroy charts in React.js using Chart.js?

I've been trying to find how to destroy chart in React.js but i couldn't find any of way.我一直试图找到如何在 React.js 中销毁图表,但我找不到任何方法。 Does anyone know how to do it??有谁知道怎么做??

Ok, so the component receive type prop?好的,所以组件接收type道具? You can call it in the useEffect with deps array of this type prop.您可以在 useEffect 中使用这种type的 prop 的 deps 数组调用它。 That is exactly what is the useEffect for.这正是 useEffect 的用途。 When type changes, you create side effect.type改变时,你会产生副作用。 (destroy and reinit chart) (销毁并重新初始化图表)

https://chartjs.org/docs/latest/developers/api.html#destroy https://chartjs.org/docs/latest/developers/api.html#destroy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM