Uncaught Error: Minified React error #200

Viewed 26408

I am a beginner in React,Not able to debug the error

This is my code using components in React.

I am trying to simulate a google Search Image result with Image,caption and Link, but on the browser all I see is an empty screen.

The error statement is :

Uncaught Error: Minified React error #200; visit https://reactjs.org/docs/error-decoder.html?invariant=200 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    at Object.I.render (react-dom.production.min.js:238)
    at <anonymous>:99:10
    at n (babel.min.js:12)
    at r (babel.min.js:12)
    at o (babel.min.js:12)
    at u (babel.min.js:12)
    at E (babel.min.js:1)

The error doesn't specify which line or anything. and the link says

The full text of the error you just encountered is:
Target container is not a DOM element.

    <html>
        <head>
            <script src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
            <script src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
            <script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
        </head>
    
        <body>
            <div id = "container"></div>
            <script type = "text/babel">
                var destination = document.getElementsByClassName("container");
    
                class ResImg extends React.Component{
                    render(){
                        return(
                            <img src = "https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.insider.com%2Fthe-batman-2021-movie-details-information-2020-2&psig=AOvVaw0AeAaWCyxcHCYi3PRMc6VS&ust=1601364735924000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCJi85taqi-wCFQAAAAAdAAAAABAD"></img>
                        )
                    }
                }
    
                class ResCaption extends React.Component{
                    render(){
                        return(
                            <p>Batman 2021</p>
                        )
                    }
                }
    
                class ResLink extends React.Component{
                    render(){
                        return(
                            <a href = "https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.insider.com%2Fthe-batman-2021-movie-details-information-2020-2&psig=AOvVaw0AeAaWCyxcHCYi3PRMc6VS&ust=1601364735924000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCJi85taqi-wCFQAAAAAdAAAAABAD"></a>
                        )
                    }
                }
    
                class SearchRes extends React.Component{
                    render(){
                        return(
                            <div>
                                <ResImg/>
                                <ResCaption/>
                                <ResLink/>
                            </div>
                        )
                    }
                }
    
                ReactDOM.render(
                    <SearchRes/>,destination
                )
            </script>
        </body>
    </html>

3 Answers

Whenever you see such an error you can visit the page it suggests to see the full error. So, when opening https://reactjs.org/docs/error-decoder.html?invariant=200 , you can see that

Target container is not a DOM element,

meaning that you try to render your app into a wrong dom node. The problem is here:

var destination = document.getElementsByClassName("container");,

you need to use getElementById instead of getElementsByClassName

Just change this

var destination = document.getElementsByClassName("container");

to

var destination = document.getElementById("container");

There is in your code you are trying this

   var destination = document.getElementsByClassName("container");

it return array of elements where what you have to do it to use it like this

   var destination = document.getElementById("container");

as you are using id="container" so you have to use it.

Related