Skip to content
IT glossary
FrontendUpdated December 3, 2026

React

A JavaScript library for building user interfaces from reusable pieces called components. You describe what each piece should look like for the current data, and React updates the interface when that data changes.

The component model

Think of a shopping cart as a group of components: a list of items, a quantity control, and an order summary. Each component describes one part of the interface. A product row can render any product because its parent passes in the name and price as inputs called props. The row can read those inputs but should not modify them.

This approach is declarative: instead of writing instructions to find and update several page elements, you describe what the interface should show for the current inputs. Most React code uses JSX, a JavaScript syntax extension that lets you write markup-like expressions alongside regular JavaScript. JSX describes UI; it does not produce browser DOM nodes on its own.

What happens when data changes?

A component can keep local state with a hook such as useState. State persists across renders, and calling its setter queues an update. The event handler still sees the state from the render that created it. If the next value depends on the previous one, pass an updater function so React can apply it to the latest value in the queue.

Rendering means calling components to calculate what the UI should look like. React reconciles that result with the previous tree, then commits the necessary DOM changes through React DOM. A component can render without any DOM changes, so seeing a component function run is not evidence that the browser rebuilt that part of the page.

Example: a quantity button

import { useState } from 'react';

function QuantityButton({ productName }) {
  const [quantity, setQuantity] = useState(1);

  return (
    <button onClick={() => setQuantity(q => q + 1)}>
      {productName}: {quantity}
    </button>
  );
}

The parent supplies productName, while each mounted button has its own quantity. A click queues a state update; the next render describes the same button with a different number. If a cart total also needs the quantity, move that state to the closest common parent and pass it down rather than keeping two copies in sync.

Where React fits

React can power a single interactive widget on an existing page or the entire UI of a web app. The core library does not prescribe routing or a data-fetching strategy. A framework such as Next.js adds application-level pieces, including routing and server rendering.

Common mistakes and interview topics

Treat state as a snapshot: mutating an array in place does not schedule an update. Pass a new array to the setter instead. Likewise, if a value can be calculated during render, you usually don't need to store it separately or synchronize it with useEffect.

Interviewers often ask you to trace a state update or debug a list whose rows keep the wrong state after reordering. A stable key tells React which row is which across renders. An array index identifies a position, not the item that occupies it.