Let’s continue with our previous article: ReactJS Environment Setup where we have created a ReactJS application which has the default code, how to start and stop it, and various files that exist in the application.
Let’s change the default code in the application and write our own code to create an application. Start the application and do not close it. Whatever change you make in the code, once you save it, it will automatically gets reflected in the browser.
Follow the below steps:
- Delete all the files in src folder.
- Create a new file in src folder: index.js. The browser will display nothing as there is no code to display.
- Write the following code in index.js file. import the necessary libraries or other dependencies.
// Import the React and ReactDOM libraries
import React from 'react';
import ReactDOM from 'react-dom';
// Create a React component. This is a function based component.
const App = function() {
return <div>Hello World!</div>;
};
// Take the React component and display it on the screen.
// There is div element with id='root' present in index.html in public folder.
ReactDOM.render(
<App />,
document.getElementById('root')
);



