Getting Started with React JS
Last updated
Last updated
In this tutorial, we’ll learn how to set up React and create a simple app that prints “Hello World” on the screen.
Basic Knowledge: Familiarity with JavaScript and HTML.
Tools to Install:
(comes with npm).
A text editor like VS Code.
Download Node.js from the official website: .
Install Node.js and verify it by running the following commands in the terminal:
If installed correctly, these commands will display the versions of Node.js and npm.
React provides a tool called Create React App to set up everything automatically.
Open your terminal and run the following command:
This command will create a folder named hello-world-app with all the necessary files.
The process might take a few minutes as it downloads dependencies.
Navigate to your project folder:
To start the React development server:
This will open your app in the browser at http://localhost:3000/
.
By default, you’ll see the React logo and some boilerplate text.
Open the project folder in your text editor (VS Code).
Locate the file src/App.js
.
Replace the code inside App.js
with the following:
Save the file.
Go back to your browser. It will automatically refresh and display:
React Components: The App
function is a React component that returns HTML (written as JSX).
JSX: Lets you write HTML inside JavaScript, making it easy to design the UI.
Live Reloading: Any changes you make in the code automatically update the browser.
You’ve successfully installed React and printed your first “Hello World” using React JS! 🎉