Facing an incredibly odd hydration error, causing data to disappear and only happens inside client
Unanswered
Blackpoll Warbler posted this in #help-forum
Blackpoll WarblerOP
Hey guys, I'll try to explain it as indepth as I can.
I have this page structure:
directory, fetches data on server side, all data is present
rendering a listing page in
If I make this card component with
To solve this the only way possible right now is to remove
I literally have no clue as to why data would disappear like this, on a console log on the client side it's literally not there anymore, it happens with multiple data points but the confusing part is that it doesn't happen with ALL of them
Here's my fetch function ran in the server in
I have this page structure:
directory, fetches data on server side, all data is present
rendering a listing page in
page.tsx -> into a Card.tsx componentIf I make this card component with
use client at the top, then some of my data just disappears, see attached video of me constantly refreshing the page, so the data is there and then it hydrates and it disappears with no useful error.To solve this the only way possible right now is to remove
use client from all cards and then it works just fine, however I need some client side hooks like useRefI literally have no clue as to why data would disappear like this, on a console log on the client side it's literally not there anymore, it happens with multiple data points but the confusing part is that it doesn't happen with ALL of them
Here's my fetch function ran in the server in
page.tsx const nextCookies = cookies()
const token = nextCookies.get('payload-token')
const results = await fetch(process.env.NEXT_PUBLIC_API_URL, {
method: 'POST',
...{
credentials: 'include',
headers: {
'content-type': 'application/json',
...(token?.value && {
Authorization: `JWT ${token.value}`,
}),
},
},
...(token?.value
? {
cache: 'no-store',
}
: {
next: {
revalidate: 600,
},
}),
body: JSON.stringify({ query: GetSupplierBySlugDocument, variables: { slug: slug } }),
})3 Replies
Blackpoll WarblerOP
Just to add additional information here:
So if I turn every component to a server one, in a build environment the data is present until I navigate away from it and come back, if I refresh the page its there again
This is on version 13.5.2, 13.4.x AND on the latest canary-3
So if I turn every component to a server one, in a build environment the data is present until I navigate away from it and come back, if I refresh the page its there again
This is on version 13.5.2, 13.4.x AND on the latest canary-3
Blackpoll WarblerOP
More information still as I try to debug it, I tried pre-filtering, memoisation and a few other things, in the console log it's here but you can see it disappear under the
use client component under the titlethe one that stays is the one that doesnt use it, incredibly odd