hydration
Unanswered
Lakeland Terrier posted this in #help-forum
Lakeland TerrierOP
Where should I begin to diagnose and treat hydration errors? App will preform as intended for 100s of actions and then hang up with a hydration error. Im having a hard time sorting out how I can remedy, I am using react 19.
18 Replies
why are you using react 19 @Lakeland Terrier
@Arinji why are you using react 19 <@272495837744201728>
Lakeland TerrierOP
Building from scratch and I want to use the bleeding edge tech
I wouldn't use react 19.. atleast until it's stable.. try downgrading to 18 and show which code has the hydration error
(by the way, the hydration error is 99% not related to whether they use react 19 or 18)
Lakeland TerrierOP
I have tracked it down to the specific client component causing the issue.
https://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading#nextdynamic
I am going to try implementing this and see if it stops the issue.
I am not downgrading to react 18, I am trying to stay ahead of the curve. My app is super simple, just a basic UI with some CRUD happening. Nothing crazy, very vanilla.
https://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading#nextdynamic
I am going to try implementing this and see if it stops the issue.
I am not downgrading to react 18, I am trying to stay ahead of the curve. My app is super simple, just a basic UI with some CRUD happening. Nothing crazy, very vanilla.
@joulev (by the way, the hydration error is 99% not related to whether they use react 19 or 18)
I don't really trust canary versions since there is a high chance there is a bug that's just not fixed
@Lakeland Terrier I have tracked it down to the specific client component causing the issue.
https://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading#nextdynamic
I am going to try implementing this and see if it stops the issue.
I am not downgrading to react 18, I am trying to stay ahead of the curve. My app is super simple, just a basic UI with some CRUD happening. Nothing crazy, very vanilla.
In that case just send your code.. ideally 19 will show you exactly what the server got vs what the client sent
Lakeland TerrierOP
https://vercel.com/docs/infrastructure/data-cache
Now I believe my issues are arising from the vercel data cache? Do I need to employ this tag based revalidation on each of my pages? When a user is logged in, I dont want anything cached. I want fresh database calls and everything updated.
Now I believe my issues are arising from the vercel data cache? Do I need to employ this tag based revalidation on each of my pages? When a user is logged in, I dont want anything cached. I want fresh database calls and everything updated.
Lakeland TerrierOP
Or maybe I am just an idiot and was returning a <div> inside a <p> by mistake
Lakeland TerrierOP
Nope not just that. I only get these errors in production. I need to implement error handling so that I can get the logs and see what is going on.
Lakeland TerrierOP
I am not hydrated but am begining to understand the issues. Can close this tooic for now, will update with greater understanding later.
Lakeland TerrierOP
My error was not cache/hydration. Garbage in garbage out, I was referencing the wrong id in my action. It mistakenly worked on first instance but not second because the id's just happened to be the same on first usage. I learned a lot about cache and hydration.
@Arinji I don't really trust canary versions since there is a high chance there is a bug that's just not fixed
Hydration error happens when we have different html payload rendered on the server and on the client. I also don't think it's related to the react version.
@James4u Hydration error happens when we have different html payload rendered on the server and on the client. I also don't think it's related to the react version.
Again, yes correct logic. I just dont trust canary versions in general.. if its a bug it shld be replicable on both 18 and 19
Lakeland TerrierOP
Is there a way to enable detailed error messages (instead of the minified versions) in vercel production deployment? It would nice to be able to enable when needed to track down specific issues.
Hmm Vercel team is working hard on friendly hydration error messages.
You can simply dynamically load the component with
ssr: false if you are sure that those components are not important in terms of SEO@James4u You can simply dynamically load the component with `ssr: false` if you are sure that those components are not important in terms of SEO
Lakeland TerrierOP
Yes that has been helpful