How to properly handle onSeriesColorChange

I want to recreate the legend from the Angular graph plugin with the new React plugin. I have done this with the GraphLegend component from @grafana/ui. I understand how to setup all of the series and settings, but I am having trouble with changing the color of the series with the color picker.

Here is a snippet that contains all the variables and functions that are used for rendering the legend.

When I have this code the result is that I dont even get the color picker displayed anymore, unlike before when I left out the onSeriesColorChange attribute, and it did display the color picker but did not change colors of the series.

I am wondering what is the correct way to handle this event and get data out of it. Also note that I did check out the GitHub demo for graph2 and found out that their solution was to override pretty much every event. I have everything I need to work already done so I am not doing it like that. The only thing I need to know is how to get data from changing the colors with the color picker.

Thanks for the help in advance!