Jet Academy Logo
Məzmunə keç / Skip to content

What is React.js ?

React.js, or simply React, is a JavaScript library used to build interactive user interfaces. With React, a web application's interface can be divided into small, independent, and reusable parts called components. In simple terms, elements such as menus, product cards, search fields, buttons, modal windows, and other interface sections can each be created as separate React components. For example, an online store may contain hundreds of product cards. Instead of writing the same HTML structure separately for each product, you can create a single ProductCard component and reuse it with different product data. React is widely used especially for developing dynamic and interactive web applications.

What Is React Used For?

React is used to build Frontend interfaces that users interact with.

With React, developers can create:

  • product catalogs;
  • personal dashboards;
  • admin panels;
  • social platforms;
  • booking systems;
  • e-commerce websites;
  • various web applications.

One of React's main advantages is that it allows the interface to be divided into components.

For example, a dashboard may consist of components such as:

  • Header
  • Sidebar
  • UserProfile
  • StatisticsCard
  • NotificationList

Each component performs its own function and can be reused on other pages when needed.

How Is React Different from JavaScript?

JavaScript is a programming language. React is a library that works with JavaScript. With JavaScript, developers can directly select and modify DOM elements and manage events. In React, developers usually describe how the interface should look for a particular state. When the state changes, React re-renders the relevant parts of the interface. For this reason, it is important to understand JavaScript fundamentals before learning React.

In particular, knowledge of:

  • functions;
  • Arrays and Objects;
  • destructuring;
  • modules;
  • Scope;
  • arrow functions;
  • async/await;
  • working with APIs

provides a strong foundation for learning React.

Is React a Framework?

React is often called a framework, but officially it is presented as a JavaScript library. React mainly focuses on building user interfaces and managing components. Additional tools and frameworks may be used for routing, full application structure, server-side rendering, and other features. For example, Next.js is a framework built on React that provides routing, server rendering, data fetching, and other capabilities for building complete web applications.

What Is a Component?

A Component is one of the core concepts in React. A component is a reusable block of code that describes a specific part of the user interface. In modern React, components are mainly created as JavaScript functions.

For example:

function Welcome() {

return <h1>JET Academy</h1>;

}

Here, a simple React component called Welcome is created.

It can then be used inside another component:

function App() {

return (

<div>

<Welcome />

</div>

);

}

The component-based approach helps divide large interfaces into smaller and more manageable parts.

What Is JSX?

JSX is a syntax that allows developers to write HTML-like markup inside JavaScript.

For example:

const title = <h1>We Are Learning React</h1>;

Although it looks similar to HTML, JSX is processed as part of the JavaScript ecosystem.

Most React components are written using JSX.

JavaScript expressions can also be used inside JSX using curly braces {}.

For example:

function Student() {

const name = "Murad";


return <h2>Hello, {name}</h2>;

}

JSX is not mandatory, but it is widely used in React projects.

What Are Props?

Props are used to pass data into a component from outside.

For example, the same CourseCard component can be used for different courses:

function CourseCard({ title }) {

return <h2>{title}</h2>;

}

Then:

<CourseCard title="Frontend Programming" />


<CourseCard title="Full-Stack Programming" />

Here, title is a prop.

Props allow the same component structure to be reused with different data. In React, props are not data that a component should directly modify itself. A parent component passes data to a child component, and the child displays the interface based on that data.

What Is State?

State is used to store data inside a component that can change over time.

For example, we can create a component that shows how many times a user has clicked a button:

import { useState } from "react";


function Counter() {

const [count, setCount] = useState(0);


return (

<button onClick={() => setCount(count + 1)}>

{count}

</button>

);

}

Here, count stores the current value. setCount is used to update the state. When state changes, React re-renders the component based on the new data.

Many interactive elements can be managed using state, including:

  • forms;
  • dropdown menus;
  • shopping carts;
  • active tabs;
  • modal windows.

What Is the Difference Between Props and State?

Props and State are both used to work with data inside components, but they serve different purposes. Props are usually data passed from a parent component to a child component. State is data that can change based on the component's own behavior and user interactions. For example, the name and price of a product card can be passed through props. Whether the user has added that product to favorites can be managed with state.

What Are React Hooks?

Hooks are special functions that allow function components to use different React features.

Some of the most commonly used Hooks in React include:

  • useState;
  • useEffect;
  • useContext;
  • useRef;
  • useReducer.

Hook names usually start with use.

For example:

const [user, setUser] = useState(null);

Here, useState allows state to be created for the component. React Hooks follow certain rules. They should be called at the top level of a component or inside a custom Hook.

What Is useState?

useState is a Hook used to store and update state inside a component.

For example:

const [darkMode, setDarkMode] = useState(false);

Here, darkMode represents the current state, while setDarkMode is the function used to update it.

When the user clicks a button, the state can be changed with:

setDarkMode(true);

What Is useEffect?

useEffect is one of the React Hooks used when a component needs to synchronize with external systems.

For example, it can be used to:

  • create external subscriptions;
  • work with browser APIs;
  • manage data fetching from a server in certain cases.

A simple example:

import { useEffect, useState } from "react";


function Users() {

const [users, setUsers] = useState([]);


useEffect(() => {

fetch("/api/users")

.then(response => response.json())

.then(data => setUsers(data));

}, []);


return <div>{users.length} users</div>;

}

Here, after the component is created, a request is sent to the API and the result is stored in state. Modern React projects may also use frameworks and specialized data-fetching libraries for retrieving data.

What Is useRef?

useRef can be used to store data that is not required for rendering or to obtain a reference to a DOM element.

For example:

import { useRef } from "react";


function Search() {

const inputRef = useRef(null);


function focusInput() {

inputRef.current.focus();

}


return (

<>

<input ref={inputRef} />

<button onClick={focusInput}>

Search

</button>

</>

);

}

Here, when the button is clicked, focus is moved to the input element.

How Do Events Work in React?

React uses event handlers to respond to user interactions with the interface.

For example:

function Button() {

function handleClick() {

alert("Clicked");

}


return (

<button onClick={handleClick}>

Click

</button>

);

}

In React, events such as:

  • onClick;
  • onChange;
  • onSubmit

can be used to run functions based on user actions.

What Is Conditional Rendering in React?

Sometimes a specific part of a component should only be displayed under certain conditions.

For example:

function Profile({ loggedIn }) {

return (

<div>

{loggedIn

? <p>Welcome to your profile</p>

: <p>Please log in</p>}

</div>

);

}

This approach is called Conditional Rendering.

It can be used to manage:

  • login status;
  • loading states;
  • error messages;
  • different UI states.

How Are Lists Displayed in React?

JavaScript's map() method is often used to convert data inside an Array into components.

For example:

const courses = [

"Frontend",

"Full-Stack",

"Java Backend"

];


function CourseList() {

return (

<ul>

{courses.map(course => (

<li key={course}>

{course}

</li>

))}

</ul>

);

}

React uses key to distinguish between list elements. A key should identify the corresponding data as uniquely and consistently as possible.

How Does React Work with APIs?

In real React applications, data is often retrieved from a Backend server through an API. For example, if a product list is stored on the server, the Frontend can retrieve it through an API.

A simple process looks like this:

React Application → API Request → Backend → Database → API Response → React UI

In JavaScript, tools such as fetch() or Axios can be used to send requests to APIs. For this reason, understanding APIs is important for React and Frontend Development in general.

What Is the Context API?

Sometimes data needs to be passed to components located far down the component tree. Passing props through every level can make the code more difficult to manage in some situations.

This is often called props drilling. React Context allows specific data to be accessed by components deeper in the component tree.

For example, Context can be used to share:

  • dark/light theme;
  • language selection;
  • some user information.

However, Context is not an automatic solution for every state management problem. It should be used according to the needs of the project.

What Is Redux and How Is It Related to React?

Redux is a separate JavaScript library that can be used to manage application state.

In smaller React projects, tools such as:

  • useState;
  • useReducer;
  • Context

may be enough.

When many components need to work with shared and complex state, additional state management tools such as Redux Toolkit can be used. JET Academy's Frontend program also teaches state management with Redux and Redux Toolkit after React.

Can React Be Used with TypeScript?

Yes.

React projects can be developed using both JavaScript and TypeScript.

TypeScript allows developers to define the types of:

  • props;
  • state;
  • API responses;
  • various data structures

inside React components.

For example:

type CourseProps = {

title: string;

duration: number;

};


function Course({

title,

duration

}: CourseProps) {

return (

<p>

{title} — {duration} months

</p>

);

}

This approach can help detect type-related errors earlier and make code clearer, especially in large projects.

What Is the Difference Between React and Next.js?

React is a library used to build user interfaces. Next.js is a framework built on React for developing complete web applications.

React mainly focuses on:

  • components;
  • UI logic.

Next.js provides additional application-level features such as:

  • routing;
  • server and client components;
  • data fetching;
  • rendering strategies.

For this reason, React and Next.js should not be considered direct alternatives. Next.js uses React.

A common learning path may be:

JavaScript → React → TypeScript → Next.js

Are React and React Native the Same Thing?

No.

React is mainly used to build web user interfaces. React Native is a technology that uses React principles to build mobile applications for iOS and Android. Instead of HTML elements such as div and button, React Native uses components designed for mobile platforms.

What Are the Advantages of React?

One of React's main advantages is its component-based approach. The same UI section can be reused across different pages, and dividing large interfaces into smaller parts can make projects easier to manage.

Other advantages of React include:

  • a large ecosystem;
  • support for JavaScript and TypeScript;
  • integration with different state management and routing solutions;
  • the ability to extend projects with frameworks such as Next.js.

Are There Any Disadvantages to React?

React is not necessary for every project. Using React for a small page with little or no interactivity may add unnecessary complexity.

Because React is primarily a UI library, larger applications may require additional decisions related to:

  • routing;
  • data fetching;
  • state management;
  • testing;
  • project architecture.

It is also important for beginners to understand JavaScript well before learning React. Simply memorizing React syntax is not enough in the long term.

Where Should You Start Learning React?

Before learning React, it is useful to know HTML, CSS, and especially JavaScript fundamentals.

A strong JavaScript foundation includes topics such as:

  • functions;
  • Arrays and Objects;
  • destructuring;
  • modules;
  • Scope;
  • DOM;
  • Events;
  • async/await;
  • working with APIs.

After that, you can follow a learning path such as:

JavaScript Fundamentals → JSX → Components → Props → State → Events → Hooks → Forms → API → Routing → State Management → TypeScript → Next.js

When learning React, building practical projects is more useful than only watching tutorials.

For example, you can build:

  • a To-Do application;
  • a product catalog;
  • a weather application;
  • a personal dashboard;
  • a simple e-commerce project that works with an API.

If you want to learn React.js, JavaScript, TypeScript, Redux Toolkit, Next.js, and other modern Frontend technologies through real-world projects, you can explore JET Academy's Frontend Programming Course.

Fill the form to learn more about our IT courses

Start learning IT today