Duration
4 min
Access
Pro
Transcript
Available

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.