Since my code base is quite big I will not add an example. Hopefully my question is clear enough.
I am using react-chartjs-2 in order to create a doughnut chart. I notice that every state change will probably trigger and event on the chart. I can’t figure it out how to prevent the chart from render.
Any idea how to disable this behavior ?
Thank you
I imagine that if your component does not render it will not trigger a rerender in your chart, you could wrap your chart in a new component and use React.memo
with your condition to render or not the chart, but take to avoid rendering bugs with memo
it would be your last option used for performance improvements.
React is VERY fast and there are so many things I can think of for you to do with your time that would be better than optimizing things like this
Kent C. Dodds https://kentcdodds.com/blog/usememo-and-usecallback