How can I use document within my component?
Unanswered
Jimdog posted this in #help-forum
JimdogOP
I've made a function called hidePopups which is being used within my html img tag within my component. The issue is, when I write it outside of a useEffect, I get document is not defined reference error. When I try use it within a useEffect, it's out of scope.
Do I need to make a seperate file and import it as a function or something?
Do I need to make a seperate file and import it as a function or something?
1 Reply
Ray
try
function hidePopups() {
if (typeof window !== 'undefined') {
let pops = .....
}
}