Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Update state asynchronously in React using Promise and setState()

    reactReact
    ^16.0.0

    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.