Update state asynchronously in React using Promise and setState()

Erik Aybar
InstructorErik Aybar

Share this video with your friends

Send Tweet

In this lesson we will look at updating state in React based on the successful resolution of a promise making use of Promise.prototype.then. We will perform a user action such as clicking a button to delete an item and fire off a request to our API. Once our request is complete, we will update our component state based on current state using setState() with an updater function and remove the target item from the list with Array.prototype.filter.