useOptimistic
code:ts
export default function LikeButton({ tweet }: Props) {
tweet.likes,
(state, newLikes: number) => state + newLikes
);
return (
<button
onClick={async () => {
addOptimisticLikes(1);
await likeTweet(tweet.id);
}}
{optimisticLikes} Likes
</button>
);
}