Create a simple "Hello, World!" application in React.js
follow these steps:
Set Up React Environment: Make sure you have Node.js and npm (Node Package Manager) installed on your machine. You can verify the installation by running the following commands in your terminal:
node --version
npm --version
Create a React App: Open your terminal and navigate to the desired directory where you want to create your React app. Run the following command to create a new React app using Create React App:
npx create-react-app hello-world-app
Navigate to the App Folder: Once the app is created, navigate to the app folder by running the following command:
cd hello-world-app
Edit the App Component: Open the src/App.js file in a code editor and replace its content with the following code:
jsx
import React from 'react';
function App() {
return (
<div>
<h1>Hello, World!</h1>
</div>
);
}
export default App;
Start the Development Server: Save the file and return to the terminal. Run the following command to start the development server:
npm start
View the App: Open your web browser and visit http://localhost:3000. You should see the "Hello, World!" message displayed on the page.
Congratulations! You have created a basic "Hello, World!" application in React.js.