React First App not working


I am following the React course and tried the hello world app. Initially, when I added the console.log(element), it was shown in the console. Then I added the render() also. From then, I am not able to see the element on the browser and also the log statement on the console. I am not able to understand what was wrong with this below code. I followed the instructions as mentioned in the videos.

import React from 'react';
import ReactDOM from 'react-dom';

const element = <h1>Hello World!</h1>;
ReactDOM.render(element, document.getElementById("root"));

Please help me with this. This JS code is not rendering element on the browser.

Hi please run the below three line code.

npm rm -g create-react-app
npm install -g create-react-app
npx create-react-app my-app

Thanks @kunalP, This worked.