Replies: 2 comments 4 replies
-
I wish someone can help on it. Can anyone? |
Beta Was this translation helpful? Give feedback.
-
I looked at your code and found your selectedDateAtom is initialized in the client rendering time with different time from the server. (new Date() will return different value). it is derived through And there is some more points that may help you below: Not sure if my method is one of the best practice, but I am following this practice to avoid server/client mismatch. Hope this helps.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
With a Next 13 app directory structure like:
When using
useHydrateAtoms
, I was getting server / client mismatch errors (in this case I was usingsuppressHydrationWarning
because timezones will intentionally differ).Even when I was so bold as to add a
typeof window === 'undefined' ? <></> : <ActualCode>
to the return statement, it still would complain.But when I use
useEffect
, it works.There are a few things in play:
Anyhoo -- thanks for reading through this far :-)
Beta Was this translation helpful? Give feedback.
All reactions