Delete trace by name from plotly.graph_object

Delete trace by name from plotly.graph_object - Is this possible? The only way that I can think of, would be to overwrite fig['data'] with itself minus the track to delete, which seems quite clumsy

found a way:
the callback needs to have a State('figure', 'figure') โ†’ fig_state
then one can use:

for i, trace in enumerate(fig_state['data']):
   if 'name' in trace and trace['name'] == 'name_to_be_deleted':
      patched_fig['data'][i].clear()