React (with Hooks, React 19 & Next.js basics)
What it is & where it is used
React is a JavaScript library for building user interfaces from components, created at Facebook (Meta) by Jordan Walke and open-sourced in 2013. It is the most widely used frontend library.
Core ideas:
- Declarative UI — describe what the UI should look like for a given state; React updates the DOM.
- Components — functions returning JSX; compose them like building blocks.
- One-way data flow — data flows down via props; events flow up via callbacks.
- State + re-render — when state changes, React re-renders the component and reconciles the result against the previous render, updating only what changed in the DOM.
- Hooks (2019) — state and side effects in function components.
- "Learn once, write anywhere" — React DOM (web), React Native (mobile), React Server Components.
React is a library; for routing, data fetching, SSR and bundling you add tools or use a framework such as Next.js or React Router (framework mode, formerly Remix) — the React docs recommend starting new apps with a framework (or Vite for a pure client app). Create React App was deprecated in February 2025.
Versions & history
| Version | Date | Highlights |
|---|---|---|
| 0.3 | May 2013 | Open-sourced at JSConf US |
| 0.14 | 2015 | react / react-dom split, stateless function components |
| 15 | Apr 2016 | Version jump from 0.14; createElement DOM rendering |
| 16 | Sep 2017 | Fiber reconciler, fragments, error boundaries, portals; 16.3 new Context API; 16.8 (Feb 2019) Hooks |
| 17 | Oct 2020 | No new features — gradual upgrades, new JSX transform (no import React needed) |
| 18 | Mar 2022 | Concurrent rendering, createRoot, automatic batching, useTransition, useDeferredValue, useId, streaming SSR with Suspense |
| 19 | Dec 2024 | Actions, useActionState, useOptimistic, use(), form action, ref as a prop, Server Components & Server Actions stable, document metadata, resource preloading |
| 19.1 / 19.2 | 2025 | Owner stacks; 19.2 (Oct 2025): <Activity>, useEffectEvent, partial pre-rendering, cacheSignal |
Ecosystem milestones: React Compiler 1.0 (Oct 2025 — automatic memoisation), React Native New Architecture default (0.76, 2024), React and React Native moved to the React Foundation under the Linux Foundation (announced Oct 2025). Next.js: 13 (App Router, 2022), 14, 15 (2024, React 19), 16 (2025, Turbopack default).
Lifecycle
Component lifecycle (function components):
- Mount — React calls the component function (render) → commits DOM → runs
useLayoutEffect→ browser paints → runsuseEffectcallbacks. - Update — triggered by a state change, new props from the parent re-rendering, or a context change → render again → React diffs the new element tree with the old one (reconciliation) → commits minimal DOM changes → runs effect cleanups for changed dependencies, then the new effects.
- Unmount — effect cleanups run (unsubscribe, clear timers).
In development Strict Mode mounts components twice (mount → unmount → mount) to reveal missing cleanups.
Class component lifecycle (legacy): constructor → render → componentDidMount | updates: shouldComponentUpdate → render → getSnapshotBeforeUpdate → componentDidUpdate | componentWillUnmount | errors: getDerivedStateFromError, componentDidCatch.
| Class method | Hook equivalent |
|---|---|
componentDidMount | useEffect(() => {...}, []) |
componentDidUpdate | useEffect(() => {...}, [deps]) |
componentWillUnmount | cleanup returned from useEffect |
shouldComponentUpdate | React.memo |
this.state / setState | useState / useReducer |
Render phases: render phase (pure — call components, compute the tree; can be paused/interrupted in concurrent mode) → commit phase (apply DOM mutations, run layout effects, then passive effects).
Tools used to develop
| Tool | Use |
|---|---|
Vite (npm create vite@latest) | Fast client-side React setup |
| Next.js, React Router (framework), Expo (React Native) | Frameworks |
| React Developer Tools (browser extension) | Component tree, props/state, profiler |
| TypeScript | Typed props/state |
ESLint + eslint-plugin-react-hooks | Rules of Hooks, exhaustive deps |
| React Compiler (babel/SWC plugin) | Automatic memoisation |
| TanStack Query, SWR, RTK Query | Server-state fetching & caching |
| Redux Toolkit, Zustand, Jotai | Client state |
| React Hook Form + Zod | Forms and validation |
| Tailwind CSS, CSS Modules, shadcn/ui, MUI, Chakra | Styling and UI kits |
| Vitest/Jest + React Testing Library, Playwright | Testing |
| Storybook | Component development in isolation |