›bobbyencoded_
/posts/newsletter/courses/about
/posts/newsletter/courses/about

The Decode

The week's AI & software news, decoded.

Subscribe →

// © 2026 BobbyEncoded Inc. — A Canadian corporation

← Back to Blog

React Learning Path

React Learning Path, Part 3: Advanced React and React 19

November 9, 2026 · 11 min read

React, Interview Prep, TypeScript, Performance, Frontend

Part 1 covered the fundamentals and Part 2 covered daily work. This part is the senior end: how React decides what to update, how it keeps the UI responsive, and what changed in React 19. If your knowledge stopped at React 18, most of the new material is in the middle of this post.

Reconciliation: how React decides what to change

When state changes, React renders a new element tree and compares it with the previous one. Comparing two arbitrary trees perfectly is expensive, so React uses two heuristics that make it roughly linear:

  1. Different element type means a different subtree. If <ProfileCard> becomes <ProfileSkeleton> at the same position, React throws away the old subtree, including its state, and mounts a new one. The same goes for <div> becoming <section>.
  2. Keys identify children across renders. Among siblings, React matches elements by key (or by position if there's none). That's why index keys go wrong when lists reorder.

That leads to two classic tricks:

// Reset a component's state on purpose: a new key means a new instance
<ProfileForm key={userId} userId={userId} />

// Accidental state loss: defining a component inside another component
function Parent() {
  function Child() { return <input />; } // a NEW component type every render
  return <Child />;                       // so the input remounts and loses its text on every render
}

Define components at module level, never inside other components.

Fiber, in one paragraph

Since React 16, the renderer is built on Fiber: each element in the tree has a fiber, a unit of work React can start, pause, resume or throw away. The old renderer walked the whole tree in one uninterruptible go. With fibers, React can split rendering into chunks, check whether something more urgent (like a keystroke) is waiting, and give priority to it. Everything in the next section is built on that ability.

Concurrent rendering

React 18 made rendering interruptible. You don't turn on "concurrent mode"; you opt individual updates into lower priority.

useTransition: mark an update as non-urgent

import { useState, useTransition } from "react";

function FilterableList({ items }: { items: string[] }) {
  const [query, setQuery] = useState("");
  const [filter, setFilter] = useState("");
  const [isPending, startTransition] = useTransition();

  return (
    <>
      <input
        value={query}
        onChange={(e) => {
          setQuery(e.target.value);                         // urgent: the input must keep up
          startTransition(() => setFilter(e.target.value)); // can lag, and can be interrupted
        }}
      />
      {isPending && <small>Updating…</small>}
      <ul style={{ opacity: isPending ? 0.6 : 1 }}>
        {items.filter((i) => i.includes(filter)).map((i) => <li key={i}>{i}</li>)}
      </ul>
    </>
  );
}

Typing stays instant. If the user types again before the filtered list has finished rendering, React abandons that render and starts again with the newer value.

useDeferredValue: the same idea, from the reader's side

When you don't control the setter (say, the value comes in as a prop), const deferredQuery = useDeferredValue(query) gives you a copy that lags behind during heavy renders. Render the expensive part from deferredQuery.

Suspense: declare the loading state

<Suspense fallback={<Spinner />}> shows the fallback while anything inside it is waiting: a lazily loaded component, or data read through a Suspense-enabled source. You place loading boundaries in the tree instead of threading isLoading flags through every component.

import { lazy, Suspense } from "react";

const Chart = lazy(() => import("./Chart")); // code-split: loaded on first render

function Dashboard() {
  return (
    <Suspense fallback={<p>Loading chart…</p>}>
      <Chart />
    </Suspense>
  );
}

React 19: what changed

React 19 (December 2024) is the release to know in 2026.

Actions and the form hooks

An Action is an async function used in a transition. React tracks its pending state, errors and optimistic updates for you. Forms accept one directly:

import { useActionState } from "react";
import { useFormStatus } from "react-dom";

type FormState = { error?: string; saved?: boolean };

declare function updateName(name: string): Promise<void>; // your API call

async function saveName(_prev: FormState, formData: FormData): Promise<FormState> {
  const name = String(formData.get("name") ?? "").trim();
  if (name.length < 2) return { error: "Name is too short" };
  await updateName(name);
  return { saved: true };
}

function SubmitButton() {
  const { pending } = useFormStatus(); // reads the status of the enclosing <form>
  return <button disabled={pending}>{pending ? "Saving…" : "Save"}</button>;
}

function NameForm() {
  const [state, formAction] = useActionState(saveName, {});
  return (
    <form action={formAction}>
      <input name="name" />
      <SubmitButton />
      {state.error && <p role="alert">{state.error}</p>}
      {state.saved && <p>Saved.</p>}
    </form>
  );
}

No useState for loading, no preventDefault, and the form is reset after a successful action. useOptimistic completes the set: it shows a temporary value (the new comment, the liked heart) immediately and reverts automatically if the action fails.

use(): read a promise or context, even conditionally

use(promise) suspends until the promise resolves, and works with Suspense. use(SomeContext) reads context, and unlike other hooks, use may be called inside conditions and loops. One caveat: the promise must be created outside the component (passed in as a prop, or from a cache), not created fresh on every render.

Smaller changes that come up

  • ref is a regular prop for function components, so forwardRef is no longer needed (it's slated for deprecation).
  • <Context value={…}> works as a provider, as in Part 2's theme example.
  • Document metadata: <title> and <meta> rendered anywhere are hoisted into <head>.
  • Better hydration errors, showing a single diff instead of a wall of warnings.

The React Compiler

The React Compiler (1.0, October 2025) is a build-time tool that memoizes automatically. It analyses your components and hooks and inserts the equivalent of useMemo, useCallback and React.memo where they help, at a finer grain than people usually write by hand.

What it means in practice:

  • With the compiler on, most manual memoization becomes unnecessary. New code mostly shouldn't add it; existing useMemo calls can stay.
  • It relies on your code following the Rules of React: pure renders, no mutating props or state, hooks at the top level. Code that breaks the rules is skipped, and the ESLint plugin flags it.
  • It doesn't fix slow algorithms or huge lists. Virtualization and code splitting still matter.

Server Components

React Server Components run only on the server (or at build time). They can be async, read databases and files directly, and send rendered output to the browser, with none of their code in the client bundle.

// app/products/page.tsx: a Server Component (the default in the Next.js App Router)
declare const db: { products: { findMany(): Promise<{ id: string; name: string }[]> } };
import { AddToCartButton } from "./AddToCartButton"; // a Client Component

export default async function ProductsPage() {
  const products = await db.products.findMany(); // runs on the server; no API endpoint needed
  return (
    <ul>
      {products.map((p) => (
        <li key={p.id}>
          {p.name} <AddToCartButton productId={p.id} />
        </li>
      ))}
    </ul>
  );
}
// AddToCartButton.tsx: interactive, so it opts into the client
"use client";
import { useState } from "react";

export function AddToCartButton({ productId }: { productId: string }) {
  const [added, setAdded] = useState(false);
  return <button onClick={() => setAdded(true)}>{added ? "Added" : `Add ${productId}`}</button>;
}

The rules to know:

  • "use client" marks the boundary where client code starts. Components imported below that line ship to the browser and can use state, effects and event handlers.
  • Server Components can't use state, effects or browser APIs.
  • Props crossing the boundary must be serializable: data, not functions (except Server Functions).
  • "use server" marks Server Functions: functions the client can call, which run on the server. Passed to a form's action, they're Actions that hit your backend with no hand-written API route.

Don't confuse Server Components with server-side rendering. SSR renders client components to HTML for the first load, then hydrates them in the browser so they become interactive. Server Components never hydrate, because there's nothing to make interactive. Most apps use both.

React 19.2: Activity and useEffectEvent

Two additions from October 2025 that are worth knowing:

  • <Activity mode="visible" | "hidden"> hides part of the UI while keeping its state, and defers its updates while hidden. Think tabs that remember their scroll position and form input, or pre-rendering a screen the user is likely to open next.
  • useEffectEvent fixes a classic effect problem: you want an effect to read the latest value of something (like the theme in a "connected" toast) without re-running the effect when that value changes. Wrap that logic in useEffectEvent, call it from the effect, and leave it out of the dependency array.
import { useEffect, useEffectEvent } from "react";

declare function connect(roomId: string): { on(e: "connected", fn: () => void): void; disconnect(): void };
declare function showToast(message: string, theme: string): void;

function ChatRoom({ roomId, theme }: { roomId: string; theme: string }) {
  const onConnected = useEffectEvent(() => showToast("Connected!", theme)); // always sees the latest theme

  useEffect(() => {
    const connection = connect(roomId);
    connection.on("connected", () => onConnected());
    return () => connection.disconnect();
  }, [roomId]); // changing the theme no longer reconnects the chat
  return null;
}

Error boundaries

An error during rendering unmounts the whole tree unless an error boundary catches it. Boundaries are still class components (static getDerivedStateFromError to show a fallback, componentDidCatch to log). Most teams use the react-error-boundary package rather than writing the class. Boundaries don't catch errors in event handlers or async code; handle those with try/catch or your data library's error state.

Performance, at senior level

The order I'd work through:

  1. Measure with the React DevTools Profiler, and check Core Web Vitals (INP is the responsiveness one).
  2. Fix the structure: move state down closer to where it's used, so fewer components re-render, and pass expensive subtrees as children.
  3. Ship less code: code splitting with lazy, and Server Components for non-interactive parts.
  4. Render less: virtualize long lists so only visible rows exist in the DOM.
  5. Keep input responsive: transitions and deferred values for heavy updates.
  6. Memoize what's left, or let the compiler do it.

Check yourself: questions and answers

1. How does reconciliation work?

React compares the new element tree with the previous one. Elements of a different type replace the whole subtree; children are matched by key. Only the differences are committed to the DOM.

2. What is Fiber and why does it matter?

React's internal unit of work, one per element. It lets React split rendering into interruptible chunks and prioritise urgent updates, which is the foundation of concurrent features like transitions and Suspense.

3. useTransition vs useDeferredValue?

Both mark work as non-urgent. useTransition wraps the state update you control; useDeferredValue gives you a lagging copy of a value you receive, such as a prop.

4. What are Actions in React 19?

Async functions run in a transition. React manages their pending state, errors and form resets, and useActionState, useFormStatus and useOptimistic build on them. A form's action prop can take one directly.

5. What does the React Compiler do, and what does it need from you?

It memoizes components and values automatically at build time, replacing most hand-written useMemo, useCallback and memo. It needs your code to follow the Rules of React; components that break them are skipped.

6. Server Components vs SSR?

SSR renders components to HTML on the server and then hydrates them in the browser. Server Components run only on the server, ship no JavaScript, and never hydrate. They can be combined: server components for data and layout, client components for interactivity.

7. What can't a Server Component do?

Use state, effects, event handlers or browser APIs. Anything interactive goes in a component marked "use client", and props passed to it must be serializable.

8. How do you reset a component's state?

Change its key. React treats it as a new instance and mounts it fresh.

9. Why must error boundaries be class components, and what don't they catch?

The lifecycle methods that catch render errors (getDerivedStateFromError, componentDidCatch) only exist on classes. They don't catch errors in event handlers, async code, or the boundary itself.

10. What problem does useEffectEvent solve?

Reading the latest props or state from inside an effect without listing them as dependencies, so the effect doesn't re-run (and, say, reconnect) just because an unrelated value like the theme changed.

Go deeper

  • React Performance: Memoization and Code Splitting. Written for React 18; read its memoization section alongside the compiler notes above
  • React State Management: Context, Redux and Zustand
  • TypeScript with React. Its forwardRef section predates React 19, where ref is a normal prop
  • React Component Patterns

That's the path: Part 1 · Part 2 · Part 3.

Further reading

  • React docs, Preserving and Resetting State
  • React blog, React v19 and React 19.2
  • React docs, React Compiler
  • React docs, Server Components and Directives
  • React docs, useTransition, use and useEffectEvent
← Previous

Identity by Name vs by ID

Next →

React Learning Path, Part 2: How React Works Day to Day

Thoughts on this?

Tell me on X: @bobbyencoded · Share this post on X

Want more like this? Subscribe to The Decode, a weekly email on the AI and developer news worth your time.