Skip to content
Advertisement

Delete button removes all the children , instead of just the one with the key

I have researched this topic for quite some time now, yet I still cannot make the ‘Remove’ button in the child component (ControlledOpenSelect) only remove the item with the key it was passed – by using the callback function.

My ControlledOpenSelect (the child component):

JavaScript

My parent component FullComponent:

JavaScript

Thank you so much!

Advertisement

Answer

You are not passing the id to the handleRemove method . you need to pass an inline function which passes the item.id as argument

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement