codedamn

Reference error: Document is not defined.

Asked by Ashutosh Choubey about 2 years ago

0

I am running javaScript in VisualStudio. When I run the code it says "Document is not defined". I searched online but nothing is working. Please help.

2 Answers

    1

    We Have To See Your Code

    @zisanurhaque

    Zisanur Haque

    @zisanurhaque

    0

    From my experience it generally happens when you're trying to access the document object before the document loads , may be you've used document.getElementById('') inside useEffect . way to resolve this try to apply conditions like

    if(document.getElementById('')){
    	// some code ...... 
    document.getElementById('');
    // more code ....
    }
    
Your answer