React - todolist - deleting

The onClick is listened by the delete function in TodoItems which is referred in TodoList’s with the “delete” prop that initialized with a delete function in TodoList.
The actual filtering happens in TodoList, but the event listening happens in TodoItem, so, how did it work exactly? Can someone please explain the call flow?

Hi @Seaqueue - welcome to the forums! Can you post a link to the code snippet so that we can take a better look at it? :slight_smile:

Hi Kirupa, Thank you for responding! I love your tutorials! The explanations are decent and thorough!
The code is from the tutorial React-GoingFurther-Building a todolist: starting at Removing items. Building an Awesome Todo List App in React | KIRUPA.

DeleteItem is a function in the TodoList which is a functional component that has all the todo list items. You are simply referencing that method in a delete button in a single item component but you are calling the main function in the Todolist.

It makes sense, when you think about it in a way if you are going to eat something from the fridge, you have to tell the fridge which item you have eaten so the frigde removes the item. You give the frigde the item ID and the frigde job is to hold all the food items updated. One single item can tell the fridge delete me im being eaten.

1 Like