score:0

React.useEffect(() => {

  // do the calculations required for setChartData, then:
  setChartData({ ...chartData, successData, failData, categories, data });

}, [/* array of dependencies, when do you want this to be recalculated? */])

Related Query

More Query from same tag