Jonatan Matajonmatum.com
conceptsnotesexperimentsessays
© 2026 Jonatan Mata. All rights reserved.v2.1.1
Concepts

React

JavaScript library for building user interfaces through declarative, reusable components, with an ecosystem spanning from SPAs to full-stack applications with Server Components.

evergreen#react#javascript#ui#components#frontend#jsx

What it is

React is a JavaScript library for building user interfaces, created by Meta (then Facebook) and released as open source in 2013. Its core mental model: UI is a function of state. When state changes, React computes the minimal DOM difference and applies only the necessary updates.

Unlike frameworks such as Angular or Vue that offer a complete solution (routing, forms, HTTP), React focuses exclusively on the view layer. The ecosystem — Next.js, React Router, Zustand — complements what React does not include.

Component model

Everything in React is a component: a function that receives props and returns JSX. Since React 16.8 (2019), hooks replaced class components as the primary pattern:

import { useState } from "react";
 
function Counter({ initial = 0 }: { initial?: number }) {
  const [count, setCount] = useState(initial);
 
  return (
    <div>
      <p>Count: {count}</p>
      <button onClick={() => setCount((c) => c + 1)}>
        Increment
      </button>
    </div>
  );
}

The fundamental hooks:

HookPurposeWhen to use
useStateLocal stateValues that change with user interaction
useEffectSide effectsSubscriptions, fetching, synchronization with external APIs
useRefMutable referenceDOM access, values that persist without causing re-render
useMemoValue memoizationExpensive computations depending on few dependencies
useCallbackFunction memoizationCallbacks passed to optimized child components
useContextShared contextLightweight global state without prop drilling

React 19

React 19 (December 2024) introduces significant changes in how data and forms are handled:

Actions and forms. useActionState replaces the manual useState + onSubmit + try/catch pattern for forms:

import { useActionState } from "react";
 
function LoginForm() {
  const [state, submitAction, isPending] = useActionState(
    async (_prev: { error?: string }, formData: FormData) => {
      const res = await login(formData.get("email") as string);
      if (!res.ok) return { error: "Invalid credentials" };
      redirect("/dashboard");
      return {};
    },
    {}
  );
 
  return (
    <form action={submitAction}>
      <input name="email" type="email" required />
      <button disabled={isPending}>
        {isPending ? "Submitting..." : "Sign in"}
      </button>
      {state.error && <p role="alert">{state.error}</p>}
    </form>
  );
}

use() for promises and context. Allows reading promises directly in render, integrating with Suspense:

import { use, Suspense } from "react";
 
function UserProfile({ userPromise }: { userPromise: Promise<User> }) {
  const user = use(userPromise);
  return <h1>{user.name}</h1>;
}
 
// Usage with Suspense boundary
<Suspense fallback={<p>Loading...</p>}>
  <UserProfile userPromise={fetchUser(id)} />
</Suspense>

Other React 19 features:

FeatureDescription
useOptimisticOptimistic UI update before server confirmation
ref as propforwardRef no longer needed — ref is a regular prop
Metadata in components<title>, <meta>, <link> automatically hoisted to <head>
StylesheetsNative <link rel="stylesheet"> support with deduplication
React CompilerAutomatic memoization — eliminates the need for manual useMemo/useCallback

Performance patterns

React re-renders a component every time its state or props change. In large applications, this can cause performance issues:

Loading diagram...

Practical rules:

  • Do not optimize prematurely — measure first with React DevTools Profiler
  • React.memo only when the component frequently receives the same props
  • useMemo/useCallback only when the cost of recomputing exceeds the cost of memoizing
  • With React Compiler (React 19+), manual memoization becomes unnecessary in most cases

Server Components vs Client Components

Server Components fundamentally change the architecture of React applications. The distinction:

AspectServer ComponentClient Component
DirectiveNone (default in App Router)"use client" at the top of the file
ExecutionServer onlyServer (SSR) + client (hydration)
Data accessDirect (async/await, DB, filesystem)Via API or server props
InteractivityNo — no state, no effects, no eventsYes — useState, useEffect, onClick
JS bundleNot sent to the clientIncluded in the client bundle

The rule: start with Server Components by default. Add "use client" only when interactivity, state, or browser APIs are needed.

Ecosystem

CategoryOptionsNotes
Full-stack frameworkNext.js, Remix, TanStack StartNext.js dominates with ~70% of new React projects
Global stateZustand, Jotai, Redux ToolkitZustand is the most adopted for new projects
StylingTailwind CSS, CSS Modules, styled-componentsTailwind dominates in new projects
FormsReact Hook Form, FormikReact 19 Actions reduces the need for libraries
TestingVitest + Testing Library, PlaywrightTesting Library promotes user-centric tests
Micro frontendsModule Federation, single-spaFor large teams with independent deploys

Why it matters

React defined the component-based UI paradigm that dominates web development. With Server Components and React 19, it evolves from a client library to a full-stack model where server and client collaborate in the same component tree. For a senior engineer, understanding the boundary between Server and Client Components — and when to cross it — is the most important architectural decision in any modern React project.

References

  • React Documentation — Meta. Official documentation with guides, API reference, and interactive tutorials.
  • React 19 — React Team, 2024. Official announcement with Actions, use(), React Compiler, and new hooks.
  • Server Components — React. Official React Server Components reference.
  • A Complete Guide to useEffect — Dan Abramov, 2019. Deep guide on the mental model of effects in React.
  • Making Sense of React Server Components — Josh W. Comeau, 2024. Visual explanation of Server Components and their architectural impact.
  • React Compiler — React. Documentation for the compiler that automates memoization.

Related content

  • TypeScript

    Typed superset of JavaScript adding optional static types, improving developer productivity, error detection, and code maintainability.

  • Server Components

    React paradigm where components execute on the server, sending only HTML to the client, reducing the JavaScript bundle and improving performance.

  • State Management

    Patterns and libraries for managing frontend application state predictably, from local component state to shared global state.

  • Next.js

    React framework for full-stack web applications with Server Components, file-based routing, SSR/SSG, and built-in performance optimizations.

  • Micro Frontends

    Architectural pattern extending microservices to the frontend, allowing independent teams to develop and deploy parts of a web application autonomously.

  • Web Components

    Native web standards for creating reusable, encapsulated components that work in any framework or without one.

  • React MFE Template

    Reusable template for creating micro frontends with React, TypeScript, Tailwind CSS, and Vite. Includes design system, testing, and CI/CD.

  • React MFE Shell

    Micro frontend shell with a complete design system, 24 components, 666 tests, and WCAG AA compliance. Published on npm as @jonmatum/react-mfe-shell.

  • React MFE Shell Demo

    Interactive demo application for the React MFE Shell design system with PWA support, automated metrics, and component showcase.

  • React Headless Menu

    Headless menu component for React with full accessibility, zero styles, and keyboard support. Published on npm.

  • My React Library

    Boilerplate for creating React libraries with TypeScript, Rollup, Jest, Tailwind CSS, Husky, and npm publishing.

  • Tailwind CSS

    Utility-first CSS framework enabling design building directly in markup using atomic classes, eliminating the need to write custom CSS.

  • Progressive Web Apps

    Web applications using modern technologies to deliver native app-like experiences: installable, offline-capable, and with push notifications.

  • Design Systems

    Collection of reusable components, patterns, and guidelines ensuring visual and interaction consistency in digital products at scale.

  • Accessibility

    Practice of designing and developing digital products usable by all people, including those with visual, auditory, motor, or cognitive disabilities.

Concepts