How to update the Plot with new changes from backend api. React, Typescript. Getting issues while updating the Plot

I am using React with Typescript.

import Plot from 'react-plotly.js';

useEffect(() => {
    // Some logic ;
        data = newData
  }, [newData]);

I am using below code to draw the Plot, when I try to update the plot it’s not updating anything in the Plot.


Can any one help me on this.

I don’t understand this React thing well (I haven’t updated it) but I think here is the answer

I have tried this but it’s not working that way and not showing the update in the Graph.