Why does React delete the last element instead of the element that I intend to delete???? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why does React delete the last element instead of the element that I intend to delete????

When I click the delete button on any of these components, it deletes the last component at that level instead of the actual element to be deleted. Can someone please have a look at the code and suggest changes? Here is the codesandbox link https://codesandbox.io/s/quirky-greider-p6g72 Here's the dev.to question link too on how to reproduce the problem https://dev.to/swagwik/why-does-react-not-delete-the-required-component-but-deletes-the-last-sibling-2ob9 https://code.sololearn.com/W2a249a21A1A/#

6th Jul 2021, 9:47 AM
Sano Manjiro
Sano Manjiro - avatar
0 Answers