I installed react then acc to a tutorial video I deleted all files in src
directory and then created new index.js
, index.css
and app.js
and other files but now it is showing an error for me
I also googled it; some answers were corrected but rearranging script position and some were corrected by giving id root in app.js
to a <div>
but all those are not working for me.
This is the error:
Error: Target container is not a DOM element.
index.js
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
reportWebVitals();
App.js
import logo from './logo.svg';
import './App.css';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
export default App;
I just installed ReactJS and now it is showing the above error. Can someone please, help me to solve the problem?
PS: For further reference following is a screenshot of the error I get.