useTransition
今の画面を残しつつ次の画面を裏でレンダリングする
参考
code:ts
export default function LikeButton({ tweet }: Props) {
return (
<button onClick={() => startTransition(() => likeTweet(tweet.id))}>
{isPending ? "loading..." : "Like"} {tweet.likes}
</button>
);
}
likeTweetがserver action