React js Tutorial

Anitamaurya
2 min readJun 29, 2024

--

. React is a JavaScript library for building user interfaces.

. React is used to build single-page applications.

. React allows us to create reusable UI components.

Let’s dive into the details:

1.Component-Based Approach:

  • React allows developers to build reusable UI components. These components make up different parts of the user interface. For instance, you can create separate components for the navigation bar, footer, main content, and more.

2.JSX (JavaScript XML):

  • React uses a markup syntax called JSX. It’s a JavaScript syntax extension popularized by React.
  • JSX allows you to write HTML-like code directly in your JavaScript files. This close integration of markup and rendering logic makes React components easy to create, maintain, and delete.

3.Virtual DOM (Document Object Model):

  • React follows the Virtual DOM approach. When data changes, React creates a virtual representation of the updated DOM. It then efficiently updates the actual DOM by minimizing unnecessary changes.
  • This approach optimizes rendering performance, making React applications fast and responsive.

4. Interactivity and Data Flow:

  • React components receive data and return what should appear on the screen.
  • You can pass new data to components in response to user interactions (e.g., when the user types into an input field). React will automatically update the screen to reflect the changes.

5. Integration with Existing HTML Pages:

  • You don’t have to build your entire page in React. Instead, you can add React components to your existing HTML page wherever needed.

Create React App

To learn and test React, you should set up a React Environment on your computer.

This tutorial uses the create-react-app.

The create-react-app tool is an officially supported way to create React applications.

Node.js is required to use create-react-app.

Open your terminal in the directory you would like to create your application.

Run this command to create a React application named my-react-app:

> npx create-react-app my-react-app

Run the React Application

Run this command to move to the my-react-app directory:

> cd my-react-app

Run this command to execute the React application my-react-app:

> npm start

A new browser window will pop up with your newly created React App! If not, open your browser and type localhost:3000 in the address bar.

The result:

Browser opened a my-react-app

--

--