close

[Solved] React Uncaught Error: Target container is not a DOM element

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error React Uncaught Error: Target container is not a DOM element in reactjs. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How To Solve React Uncaught Error: Target container is not a DOM element Error ?

  1. How To Solve React Uncaught Error: Target container is not a DOM element Error?

    To Solve React Uncaught Error: Target container is not a DOM element Error The way you have it runs before you even have DOM. You should include it at the bottom like so.

  2. React Uncaught Error: Target container is not a DOM element

    To Solve React Uncaught Error: Target container is not a DOM element Error The way you have it runs before you even have DOM. You should include it at the bottom like so.

Solution 1

The way you have it runs before you even have DOM. You should include it at the bottom like so.

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>REACT TEST</title>
</head>

<body>
  <div id="app"></div>
  <script src="./bundle.js"></script>
</body>

</html>

Solution 2

You are inserting your React script before the initialization of the container. Make it like this:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>REACT TEST</title>
</head>

<body>
  <div id="app"></div>
  <script src="./bundle.js"></script>
</body>

</html>

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment