How can I use document within my component?
Unanswered
Jimdog posted this in #help-forum
![Avatar](https://cdn.discordapp.com/avatars/181857762165129216/daabf718d310f0327853b84695734fe6.webp?size=256)
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?
![Image](https://cdn.discordapp.com/attachments/1187047919380086834/1187047919765958746/image.png?ex=65957786&is=65830286&hm=613914f46cbba94e8695c7bc56da6cbed18754414b56744bb147a073637f6b9b&)
![Image](https://cdn.discordapp.com/attachments/1187047919380086834/1187047920034385920/image.png?ex=65957786&is=65830286&hm=2ac456b41c32e178885fa180962d248a9e120cbd785b79e7a8ae35a7631464bd&)
1 Reply
![Avatar](https://cdn.discordapp.com/avatars/743561772069421169/3c5d689eee4459a24fc420063411c016.webp?size=256)
Ray
try
function hidePopups() {
if (typeof window !== 'undefined') {
let pops = .....
}
}