Source:  Twitter logo

I have had a look at all the other posts that have had this issue, but I am still confused as to why I am running into this error. I made sure I used id in my

Just started playing with React, so I am sure its something quite silly.

Thanks for the help in advance.

Code is below.


        <div id="testing"></div>
        <script src="index.js"></script>


import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';

ReactDOM.render(<App />, document.getElementById('testing'));

Full Error message:


../app/node_modules/fbjs/lib/invariant.js:42 renderSubtreeIntoContainer
../app/node_modules/react-dom/cjs/react-dom.development.js:15144 render
▲ 3 stack frames were expanded.
  3 | import './index.css';
  4 | import App from './App';
  5 | 
> 6 | ReactDOM.render(<App />, document.getElementById('testing'));
  7 | 
  8 | 
  9 | 
View compiled
▼ 6 stack frames were expanded.
../app/webpack/bootstrap 4755e61baeec1360d412:678
../app/webpack/bootstrap 4755e61baeec1360d412:88
../app/webpack/bootstrap 4755e61baeec1360d412:678
../app/webpack/bootstrap 4755e61baeec1360d412:724
(anonymous function)

Make sure to double check the index.html you are seeing in your browser. Assuming you use create-react-app an thereby webpack it might serve you a different file either from memory or from the public folder.

Mistake was found from discussion in comments and chat.

9 users liked answer #0dislike answer #09
xDreamCoding profile pic

You need to call React.createElement() like this:

ReactDOM.render(React.createElement(<App />), document.getElementById('testing'));
2 users liked answer #1dislike answer #12
Rob Johansen profile pic
Rob Johansen

Check in your html file if the id attribute has the same name as

ReactDOM.render(, document.getElementById('index'));
0 users liked answer #2dislike answer #20
Front-end Developer profile pic
Front-end Developer

Copyright © 2022 QueryThreads

All content on Query Threads is licensed under the Creative Commons Attribution-ShareAlike 3.0 license (CC BY-SA 3.0).