React.render(); error occurs when using React.

Asked 2 years ago, Updated 2 years ago, 95 views

After installing 'npm install -g create-react-app' with npm, the project folder was created with 'create-react-app./example'.

We used 'npm start' to run it in developer mode inside the project that was created later.

For a simple example of 'Hello World' output in 'App.js', the following code is entered, but the following compilation error occurs:

ReactDOM.render(
    <h1>Hello, World!</h1>,
    document.getElementById('root')
);

The errors are as follows:

'Failed to Compile - ./src/App.js ReactDOM is not defined'

react

2022-09-22 15:32

1 Answers

at the top Add import ReactDOM from 'react-dom';


2022-09-22 15:32

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.