Go ProSign in

This Lesson is for Members

Subscribe today and get access to all lessons! Plus direct HD download for offline use, enhances transcripts, member comment forums, and iTunes "podcast" RSS feed. Level up your skills now!

Unlock This Lesson

Already subscribed? Sign In

Autoplay
Hide playlist

    Optimistically Update Multiple Values in State Using React's setState

    We'll add a method to our class-based React component and immediately update state before firing off our request. Using a setState updater function, we will update component state based on previous state and toggle the "liked" status of a tweet upon the user clicking the heart icon. We will simultaneously increment or decrement the target tweet's likes property and appropriately add or remove the tweetId from the likedTweets array.

    You must be a Member to view code