You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I've been following this course up to Chapter 17, which covers "Implementing an Optimistic UI with the React useOptimistic Hook in Next.js." I've run into an issue where, after triggering addOptimisticTweet (from the useOptimistic hook), and before the backend call is completed, the Tweets component renders twice unexpectedly. The first render correctly updates the like count, e.g., from 0 to 1. However, the second render, which shouldn't happen, resets the like count from 1 back to 0, resulting the useOptimistic hook ineffective.
Here's my full code: https://github.com/cherishh/clone-twitter
One note, though: I'm using a traditional username/password authentication method instead of OAuth. However, I don't believe this is relevant to the issue at hand.
Any assistance would be appreciated.
The text was updated successfully, but these errors were encountered:
UPDATE
Turns out it's a nextjs bug. I was originally using 14.1.0 and this problem occurs. When I change it to 13.4.7 which this tutorial uses, everything is fine.
But now I got another question: I've pulled this repository and tried again with logging the same thing. Amazingly, Tweets also renders twice, but the actual page doesn't gets updated. How does this happen??
Hi, I've been following this course up to Chapter 17, which covers "Implementing an Optimistic UI with the React useOptimistic Hook in Next.js." I've run into an issue where, after triggering
addOptimisticTweet
(from theuseOptimistic
hook), and before the backend call is completed, theTweets
component renders twice unexpectedly. The first render correctly updates the like count, e.g., from0
to1
. However, the second render, which shouldn't happen, resets the like count from1
back to0
, resulting theuseOptimistic
hook ineffective.Issue:
Tweets.tsx
LikeButton.tsx
Here's my full code: https://github.com/cherishh/clone-twitter
One note, though: I'm using a traditional username/password authentication method instead of OAuth. However, I don't believe this is relevant to the issue at hand.
Any assistance would be appreciated.
The text was updated successfully, but these errors were encountered: