Build a Basic React App that Display “Hello World!”
React is a Javascript Library that was created by Facebook for building better User Interface(UI) web applications and mobile applications. It is an open-source library for creating interactive and dynamic applications. In this article, we will see how to build a basic react app that shows Hello World.
Steps to Create React Application:
Step 1: Create a react application using the following command
npx create-react-app foldername
Step 2: Change your directory to the newly created application using the following command
cd foldername
Project Structure:
The updated dependencies in package.json file will look like:
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4",
}
Example: Now inside App.js and write down the following code as shown below:
Javascript
import React from 'react' ; import './App.css' ; function App() { return ( <h1> Hello World! </h1> ); } export default App; |
Step to Run the application: Enter the following command to run the application.
npm start
Output:
Contact Us