DEV Community

okpalavivian
okpalavivian

Posted on

react.dom.development.js:29345 Uncaught Error: createRoot(...): Target container is not a DOM element.

App.js

import React, { Component } from 'react';
import {
  BrowserRouter as Router,
  Route,
} from 'react-router-dom';
import HomePage from './pages/HomePage';
import './App.css';

class App extends Component {
  render() {
    return (
      <Router>
        <div className="App">
          <Route path="/" component={HomePage} exact />
        </div>
      </Router>
    );
  }
}

export default App; 
Enter fullscreen mode Exit fullscreen mode

index.js
import React from 'react';
import ReactDOM from 'react-dom/client';

import App from './App';

ReactDOM.createRoot(, document.getElementById('root'));

Home.js

import React from 'react';

const HomePage = () => (
<>

Hello, welcome to my blog!



Welcome to my blog! Proin congue
ligula id risus posuere, vel eleifend ex egestas. Sed in turpis leo.
Aliquam malesuada in massa tincidunt egestas. Nam consectetur varius turpis,
non porta arcu porttitor non. In tincidunt vulputate nulla quis egestas. Ut
eleifend ut ipsum non fringilla. Praesent imperdiet nulla nec est luctus, at
sodales purus euismod.



Donec vel mauris lectus. Etiam nec lectus urna. Sed sodales ultrices dapibus.
Nam blandit tristique risus, eget accumsan nisl interdum eu. Aenean ac accumsan
nisi. Nunc vel pulvinar diam. Nam eleifend egestas viverra. Donec finibus lectus
sed lorem ultricies, eget ornare leo luctus. Morbi vehicula, nulla eu tempor
interdum, nibh elit congue tellus, ac vulputate urna lorem nec nisi. Morbi id
consequat quam. Vivamus accumsan dui in facilisis aliquet.,



Etiam nec lectus urna. Sed sodales ultrices dapibus.
Nam blandit tristique risus, eget accumsan nisl interdum eu. Aenean ac accumsan
nisi. Nunc vel pulvinar diam. Nam eleifend egestas viverra. Donec finibus lectus
sed lorem ultricies, eget ornare leo luctus. Morbi vehicula, nulla eu tempor
interdum, nibh elit congue tellus, ac vulputate urna lorem nec nisi. Morbi id
consequat quam. Vivamus accumsan dui in facilisis aliquet.,


</>
);

export default HomePage;

Top comments (2)

Collapse
 
djackson1 profile image
DJack


ReactDOM.createRoot(, document.getElementById('root'));

=>

ReactDOM.createRoot(<App />, document.getElementById('root'));

`

Collapse
 
okpalavivian profile image
okpalavivian

I have been getting this error code in my console, please how do I clear it. its really stressing me out