Next.js Discord

Discord Forum

how to use ahook's useSize(document.documentElement)?

Answered
Havana posted this in #help-forum
Open in Discord
HavanaOP
Hi, i'm having major issues understanding how i'm supposed to even do this. If i use document, i get document the document doesn't exist error. If i check like this:
useSize(document?.documentElement || null) i get hydration errors... What am i supposed to do here and why does it have to be so difficult?
Answered by Giant panda
Try to use if window is not null or undefined
View full answer

1 Reply

Giant panda
Try to use if window is not null or undefined
Answer