Skip to content
Advertisement

How do I delete a list item that has been given a unique id when created, in React + Firebase?

I am creating a Todo list using React and Firebase. So far, I have already created the AddToDo functionality, however, now I am having trouble with the delete functionality. I believe this is where my problem lies. For example, when I try and click the delete icon that I set up, I get an error:

JavaScript

This is the code if it helps. AddLink.js

JavaScript

And Todo.js

JavaScript

Any help would be greatly appreciated.

Advertisement

Answer

JavaScript

You should replace props.todo.id with props.value.id.

JavaScript

Alternatively you can change:

JavaScript

To

JavaScript

The key you use to access props.value should be the same as the one declared in the jsx template. Using proptypes can help you avoid those mistakes.

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