Next.js Discord

Discord Forum

hydratation error on clock

Answered
Common Moorhen posted this in #help-forum
Open in Discord
Common MoorhenOP
Im creating a clock in a use client component, and i update the clock time with a useeffect (making sure it runs on the client), but i still get hydratation error because the initial ui doesnt match the server one.
Answered by Common Moorhen
nvm, i just fixed itthis way
View full answer

8 Replies

Common MoorhenOP
nvm, i just fixed itthis way
Answer
@Common Moorhen Im creating a clock in a use client component, and i update the clock time with a useeffect (making sure it runs on the client), but i still get hydratation error because the initial ui doesnt match the server one.
yeah time is a bit tricky with SSR because the client is almost always different from the server, it is one of the situations where the best solution is to use suppressHydrationWarning
Common MoorhenOP
I spent hours looking for a solution to then get a different error that got me to those docs
ty
Himalayan
@Himalayan Click to see attachment
Common MoorhenOP
i have been participating for a month or so
Original message was deleted
Common MoorhenOP
bruh created a private club xd