score:0

firstly, flamegraph() creates a new instance of flamegraph, you'd need to use graphref.current.destroy(). secondly, you'd want to destroy this not when the data has already been loaded, but just as it starts to load, right? because that's the operation that takes time.

consider the following:

const cleangraph = () => {
  if (graphref.current !== undefined) {
    graphref.current.destroy()
  }
}

const fetchgraph = (filters: filter) => {
  setfetching(true)
  cleangraph()
  getflamegraph(
    number(projectid),
    filters.startdate ? filters.startdate.unix() : 0,
    filters.enddate ? filters.enddate.unix() : 0,
    sourceid,
    sourceline
  )
  ...
}

Related Query

More Query from same tag