Cannot add property visible, object is not extensible

i created box plot in my React app. Everything work fine insead of clicking on legend. After click … one of the boxes should be no longer visibble but it doesnt work and im still getting this error message. Screenshot 2021-08-24 111247

Any ideas?