Sign in Go Pro

Advanced React Native

Trigger an Item Delete on Prop Change with componentDidUpdate

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson
Autoplay

Up next

Previous

About

Before we can animate the deltion of a todo item, we have to change the way the delete happens, so that the TodoItem component sticks around for long enough to animate off the screen, before being completely removed from the component tree.

We will do that by doing a "soft delete" on the todo item by setting a deleted flag. Then, it will be the responibility of the TodoItem component to delete the todo from teh API.

Summary of Content:

  • Move the API call for deleting items to a new method
  • "Soft delete" the todo item by setting a deleted flag on the item in state
  • Create a componentDidUpdate method on TodoItem to detect the deleted flag change, use setTimeout to simulate an animation delay, and then delete the item using the api call

Instructor

Links

Comments

There are no comments on this lesson, start the conversation below ...

>
You need to go PRO to post comments.

Lessons in Advanced React Native