Access visible/hidden traces in react-plotly

I’m looking for a way to detect which traces were shown/hidden by clicking the legend on a chart.
Is there a way to iterate over the traces and see if a trace is visible?