Page goes blank after rendering and navigating to one page and pressing back button
Unanswered
Spectacled Caiman posted this in #help-forum
Spectacled CaimanOP
When going to home and navigating to one route then pressing back button the page goes blank
18 Replies
Spectacled CaimanOP
and I keep getting this error and i don't know where it is coming from it is not in my code even I even suppressHydrationWarning and it still shows up
Spectacled CaimanOP
Ok i managed to solve the hydration error but still the issue is there
@Spectacled Caiman Ok i managed to solve the hydration error but still the issue is there
Sun bear
For better debugging and in general i would not recommend to have a try catch block like this.
Better fetch the database in try catch and then do it like:
Better fetch the database in try catch and then do it like:
let shares = null;
try {
const url = variables.BACKEND_URL+"/api/v1/read/latest-shares"
const request = await fetch(url, {
method: 'GET',
next: {
revalidate: 0,
}
})
const response = await request.json();
shares = response.data;
} catch (e) {
console.log(e)
}
if (!shares) {
return <>something went wrong</>
}
return (
// Expected response
)@Sun bear For better debugging and in general i would not recommend to have a try catch block like this.
Better fetch the database in try catch and then do it like:
js
let shares = null;
try {
const url = variables.BACKEND_URL+"/api/v1/read/latest-shares"
const request = await fetch(url, {
method: 'GET',
next: {
revalidate: 0,
}
})
const response = await request.json();
shares = response.data;
} catch (e) {
console.log(e)
}
if (!shares) {
return <>something went wrong</>
}
return (
// Expected response
)
Spectacled CaimanOP
ok thanks for your help. I updated it but the issue still isn't solved
@Spectacled Caiman ok thanks for your help. I updated it but the issue still isn't solved
Sun bear
What error do you see in console when you get the white screen?
@Sun bear What error do you see in console when you get the white screen?
Spectacled CaimanOP
nothing
these errors are there but these are there before the white screen also
@Spectacled Caiman nothing
Sun bear
What about server side console in your code editor
@Sun bear What about server side console in your code editor
Spectacled CaimanOP
nothing
Ok i managed to resolve it
Sun bear
Thats strange. I would first add a
console.log("test")
in the beginning of your home page.tsx. That should log serverside when you visit the homepage to test of it is rendering at all.
You should at least see an error in the terminal i would say 😅
console.log("test")
in the beginning of your home page.tsx. That should log serverside when you visit the homepage to test of it is rendering at all.
You should at least see an error in the terminal i would say 😅
@Sun bear Thats strange. I would first add a
console.log("test")
in the beginning of your home page.tsx. That should log serverside when you visit the homepage to test of it is rendering at all.
You should at least see an error in the terminal i would say 😅
Spectacled CaimanOP
no the problem was actually i apparently can't have two layout.js files
when using with radix ui theme provider
so when i deleted the one and only kept root it started working
it showed no error though
Sun bear
Ah okay