,

Installing ReactJs (create-react-app) and Printing “Hello, World” – Tutorial 2

Posted by

ReactJs Installation and Hello World Tutorial

ReactJs Installation and Hello World Tutorial

In this tutorial, we will go through the process of installing ReactJs using create-react-app and creating a simple “Hello World” application.

Step 1: Install Node.js

First, you need to install Node.js which comes with npm (Node Package Manager). You can download and install Node.js from the official website for your operating system.

Step 2: Install create-react-app

After installing Node.js, open your terminal and run the following command to install create-react-app globally:

npm install -g create-react-app

Step 3: Create a new React app

Now, you can create a new React app by running the following command in your terminal:

npx create-react-app hello-world

This will create a new folder named hello-world with all the necessary files and dependencies for your React app.

Step 4: Write the “Hello World” component

Open the src/App.js file in your code editor and replace the existing code with the following:


import React from 'react';

function App() {
return (

Hello World

);
}

export default App;

This code defines a simple functional component that renders a heading with “Hello World” text.

Step 5: Run the app

Finally, run the following command in your terminal to start the development server and view your Hello World app in the browser:

npm start

Open your web browser and go to http://localhost:3000 to see your “Hello World” application in action!

That’s it! You have successfully installed ReactJs using create-react-app and created a simple “Hello World” application. Happy coding!