TL;DR
Composition, custom hooks, compound components and the Server/Client split — the patterns that keep a React 19 app readable as it grows, with real trade-offs.
React 19 is now the settled baseline, not the new thing: 19.0 shipped December 5, 2024, 19.2 followed on October 1, 2025 with and useEffectEvent, the React Compiler reached stable 1.0 on October 7, 2025, and the current patch is 19.3.1, released October 14, 2026. What changed with that line is not the component model — it is where the work happens. Server Components fetch and render on the server, Actions replace most hand-rolled mutation code, and the compiler now owns the memoization that used to be a developer's job. The patterns that scale in this version are therefore the ones that organise where code lives and what varies, not the ones that squeeze renders out of the framework.
The short version: compose with slots instead of inheriting or drilling props, extract repeated logic into named custom hooks, share state between related components with the compound-component pattern instead of threading props through five layers, and draw the Server/Client boundary once, at the page level, instead of sprinkling 'use client' wherever the build complains. Everything below is a variation on one rule — pick the pattern by what varies: shape, logic, or shared state. If nothing varies, a plain component is the whole design.
Composition is the default, not the fallback
React has no inheritance-based component model, and that is a deliberate design choice, not a missing feature. The composition model is children and named slots: a parent renders the pieces it is given instead of a subclass overriding the pieces it inherited. The practical difference shows up the first time a page needs a different sidebar, or a card needs a different footer — with composition that is a different prop, with inheritance it is a new subclass, and with prop drilling it is a change to every component in between.
The layout pattern below is the one to copy. The Layout component knows nothing about pages; each page passes the pieces it needs. When a new page needs a different sidebar, it passes a different one. No component in the middle changes, and no prop is threaded through a component that does not use it.
// Layout owns the chrome; pages own the content. Nothing in between
// needs to know what either side renders.
function Layout({ header, sidebar, children }: {
header: React.ReactNode;
sidebar?: React.ReactNode;
children: React.ReactNode;
}) {
return (
<div className="shell">
<header>{header}</header>
<div className="body">
{sidebar && <aside>{sidebar}</aside>}
<main>{children}</main>
</div>
</div>
);
}
function SettingsPage() {
return (
<Layout header={<PageHeader title="Settings" />} sidebar={<SettingsNav />}>
<ProfileForm />
</Layout>
);
}The rule that keeps composition honest is that a slot is a seam, and a seam should be visible. If a component accepts twelve optional render props, it is not composable — it is a configuration object wearing a component's clothes. One or two slots with clear names (header, sidebar, actions) is the pattern; a component that takes a different render prop for every line of its output is a sign the component should have been two components. The React docs on composition frame the same idea as containment: specialisation by passing elements, not by subclassing.
Composition also replaces most uses of render props and higher-order components. Both were answers to the same problem — reuse behaviour across components — and both have a cost that composition does not: render props nest, and higher-order components hide the wrapped component's props behind a wrapper that is hard to type and harder to debug. A custom hook is the better answer for behaviour reuse, which is the next section. Keep render props only where the reused thing is genuinely rendering — a list that needs a custom row, a menu that needs a custom item — and even there, a slot usually reads better.
Custom hooks: extract logic, not components
A custom hook is a function that calls other hooks and returns whatever the caller needs. Its value is not reuse — a hook used once is still worth writing — it is naming. useDebouncedValue says what the code does in a way that the inline useEffect + setTimeout + cleanup never does, and it can be tested without rendering a component. The discipline is one concern per hook: a hook that fetches, debounces, validates, and tracks analytics is four hooks wearing one name, and it will be refactored the first time any one of those concerns changes alone.
// One concern: turn a fast-changing value into a settled one.
// The effect cleans up after itself, so rapid keystrokes never fire
// a stale timeout — the bug the inline version almost always has.
import { useEffect, useState } from 'react';
export function useDebouncedValue<T>(value: T, delayMs = 300): T {
const [debounced, setDebounced] = useState(value);
useEffect(() => {
const id = setTimeout(() => setDebounced(value), delayMs);
return () => clearTimeout(id);
}, [value, delayMs]);
return debounced;
}Two rules keep hooks from becoming a liability. First, hooks are for logic that is shared or named, not for hiding complexity — extracting a 40-line effect into a hook with a vague name like usePageLogic moves the mess, it does not fix it. Second, respect the Rules of Hooks (top level only, same order every render) and let the linter enforce them: eslint-plugin-react-hooks v6 shipped with React 19.2 and now carries the compiler-powered rules, so a violation is a lint error, not a runtime surprise. The 19.2 release also added useEffectEvent, for the common case where an effect needs the latest value of something that should not retrigger it — a notification theme, a logging callback — without splitting the effect or disabling the lint rule. The useEffectEvent reference shows the chat-room example where changing the theme used to reconnect the socket; with an Effect Event, it does not.
The other hook worth knowing by name is use, the stable 19.0 hook that reads a promise or a context inside a component or a hook, conditionally if needed — the first hook that is allowed to be called inside a conditional or a loop. It is the bridge between Server Components and client code: a server component passes a promise down, and the client component unwraps it with use inside a Suspense boundary. The use reference documents both forms; the promise form is the one that changes how data loading is structured, because the fetch can start on the server and resolve on the client without a loading state in between.
Compound components: shared state without prop drilling
Some components are really a family: a tab list, its panels, and the selected tab; a dialog, its trigger, and its close button; a menu and its items. Passing the selected tab through props from a parent to each child works for two children and collapses at five, because every intermediate component gains a prop it does not use and every change touches all of them. The compound-component pattern solves it with Context: the parent owns the state, the children read it from context, and the public API is the family of components, not the props.
// Tabs owns the state; TabList, Tab and TabPanel read it from Context.
// The caller composes the family and never touches the selected index.
import { createContext, useContext, useState, type ReactNode } from 'react';
const TabsContext = createContext<{ value: string; select: (v: string) => void } | null>(null);
function useTabs() {
const ctx = useContext(TabsContext);
if (!ctx) throw new Error('Tabs.* must be used inside <Tabs>');
return ctx;
}
export function Tabs({ defaultValue, children }: { defaultValue: string; children: ReactNode }) {
const [value, setValue] = useState(defaultValue);
return <TabsContext.Provider value={{ value, select: setValue }}>{children}</TabsContext.Provider>;
}
export function TabList({ children }: { children: ReactNode }) {
return <div role="tablist">{children}</div>;
}
export function Tab({ value, children }: { value: string; children: ReactNode }) {
const { value: selected, select } = useTabs();
return (
<button role="tab" aria-selected={selected === value} onClick={() => select(value)}>
{children}
</button>
);
}
export function TabPanel({ value, children }: { value: string; children: ReactNode }) {
const { value: selected } = useTabs();
return selected === value ? <div role="tabpanel">{children}</div> : null;
}
// Usage: the shape of the UI is visible at the call site, the state is invisible.
<Tabs defaultValue="overview">
<TabList>
<Tab value="overview">Overview</Tab>
<Tab value="billing">Billing</Tab>
</TabList>
<TabPanel value="overview">…</TabPanel>
<TabPanel value="billing">…</TabPanel>
</Tabs>This is the pattern that Radix UI, Headless UI, and React Aria are built on, and it is worth copying their discipline even when you build the component yourself: the parent component holds the state and the context, each child is small and does one thing, and an explicit error when a child is used outside its parent turns a silent undefined into a message that names the fix. The cost is indirection — a reader cannot see where Tab gets its selected state without opening Tabs — which is why the pattern is for genuine families, not for two components that happen to share a prop. Two siblings sharing a prop is a parent with state; five siblings sharing state is a compound component.
The anti-pattern to avoid is context as a global store. A context that holds the whole app's state and is consumed by fifty components is not the compound pattern — it is a store without the tooling, and every update re-renders every consumer unless each one is carefully memoized. Compound-component context is narrow: one family, one concern, one provider per instance, created and destroyed with the family. If the state needs to outlive the component, it belongs in a store or on the server, not in a context.
Server Components and Client Components: draw the boundary once
Server Components are stable in React 19, and they change where the patterns above live. A Server Component runs on the server, can read the database and the filesystem directly, and never ships its code to the browser. A Client Component runs in the browser and owns interactivity — state, effects, event handlers. The two are connected by props, and by the rule that a Client Component cannot import a Server Component, only receive one as a child. The Server Components reference states the boundary plainly: server for data and rendering, client for interaction.
The pattern that works is to draw the boundary once, at the page level, and keep it there. The page is a Server Component: it fetches, it renders the shell, and it passes Server Components down as children and Client Components down as leaves. The interactive pieces — the tabs from the previous section, a form, a search box — are Client Components at the leaves. The boundary is visible in the file tree, and a new developer can see it without reading the framework docs.
// app/dashboard/page.tsx — a Server Component. It fetches, renders the
// shell, and hands the interactive leaves to the client. No 'use client'
// anywhere in this file, and none needed.
import { Tabs, TabList, Tab, TabPanel } from './tabs';
import { SearchBox } from './search-box'; // 'use client' lives here, at the leaf
export default async function DashboardPage() {
const projects = await db.project.findMany({ orderBy: { updatedAt: 'desc' } });
return (
<Tabs defaultValue="active">
<TabList>
<Tab value="active">Active</Tab>
<Tab value="archived">Archived</Tab>
</TabList>
<TabPanel value="active">
<SearchBox />
<ProjectList projects={projects} />
</TabPanel>
<TabPanel value="archived">…</TabPanel>
</Tabs>
);
}Three mistakes recur. First, putting 'use client' at the top of a page because one leaf needs it — the directive applies to the whole module, so the page and everything it imports becomes client code, and the server advantage disappears. Second, fetching in a Client Component with useEffect when the data was available on the server — the round trip, the loading state, and the waterfall are all avoidable. Third, passing a Server Component into a Client Component as anything other than a child prop — it cannot be imported, and the build error that says so is the framework enforcing the boundary, not a bug to work around. Actions, the stable 19.0 form primitive, complete the picture: a form posts to a server function, the server mutates and revalidates, and the client gets the result without a hand-rolled fetch — the mutation equivalent of the Server Component fetch.
State: colocate first, lift only when shared
The cheapest state is the state that does not exist yet, and the second cheapest is state that lives exactly where it is used. Colocation is the default: a search box's query lives in the search box, a dialog's open state lives in the dialog, a tab's selection lives in the Tabs family from the previous section. State is lifted only when two components need the same value — and lifted to their nearest common ancestor, not to the top of the tree. A value lifted to the app root because two siblings three levels down share it forces every component in between to re-render on every change, and forces every future reader to understand why the root owns a search query.
Context is for state that is passed, not for state that is global. The test is whether the state changes often and whether many components read it: a theme or a locale changes rarely and is read everywhere, so context fits. A form's values change on every keystroke and are read by one component, so context is the wrong tool — every keystroke would re-render every consumer. For genuinely global, frequently changing state, a store library (Zustand, Jotai, Redux Toolkit) exists precisely because it solves the subscription problem context does not: components subscribe to slices, and only the subscribers re-render. Reaching for a store before the app needs one is the same mistake as reaching for context before the family needs one — the pattern should follow the shape of the sharing, not precede it.
Memoization in the Compiler era
The React Compiler 1.0, stable since October 7, 2025, is the single biggest change to how React code is written in this version, and it is a build-time change, not an API change: the compiler analyses components and inserts memoization automatically, including after early returns, where hand-written useMemo cannot reach. The Compiler 1.0 announcement reports up to 12% faster initial loads and over 2.5× faster interactions on Meta's production apps, and the compiler works back to React 17 — on 17 and 18 it needs the react-compiler-runtime package; on React 19 it works natively.
The practical consequence is that useMemo, useCallback, and React.memo move from default tools to escape hatches. New code written against the compiler should not memoize by hand: the compiler does it, and hand-written memoization can fight it — a useMemo with a wrong dependency array is a bug the compiler would not have written. The escape hatches stay for the cases the compiler cannot see: a value passed to a non-React consumer, a referential-equality guarantee an external library depends on, or a component that must not re-render because its parent is outside the compiler's reach. The rule is to let the compiler own memoization and keep the linter (eslint-plugin-react-hooks v6, with its compiler rules) as the check that the code is compilable — mutating props, side effects during render, and conditional hooks are now build failures, not style nits.
This also retires a whole class of performance advice. Articles written before October 2025 that tell you to wrap every callback in useCallback and every list item in memo are describing a manual technique for a problem the toolchain now solves. The patterns in this article survive the compiler precisely because they are about organisation, not optimisation: composition, hooks, compound components, and the server/client split are design decisions the compiler cannot make for you.
Head-to-head: the four patterns against the alternatives
| Composition (slots) | Prop drilling | Inheritance | Context as store | |
|---|---|---|---|---|
| What it shares | UI shape | Data, through every layer | Behaviour, via a base class | Any state, everywhere |
| Cost when it changes | One call site | Every intermediate component | Every subclass | Every consumer re-renders |
| When it is right | Layout and page shape vary | Two levels, one prop, rarely | Never in React — no model for it | Rarely changing, widely read |
| Failure mode | Twelve optional render props | Props nobody uses, everywhere | Fragile base class | Keystroke re-renders the app |
| Testability | Each piece renders alone | Props must be threaded in tests | Subclass must be instantiated | Provider must wrap everything |
The table's blunt row is inheritance: React has no inheritance-based component model, and reaching for it — a base component with overridable methods — is fighting the framework instead of using it. The other three alternatives all have a legitimate narrow use, and the failure mode in each case is the same shape: the pattern applied one level wider than the sharing it serves. Composition applied to every line of a component becomes configuration; drilling applied past two levels becomes noise; context applied to frequently changing state becomes a performance bug.
Architecture decision: composition, hooks, compound components in this codebase
useMemo, useCallback, and memo as documented escape hatches only.'use client' creeping up the tree until whole pages ship as client code.'use client' — and fix performance in review. (c) Adopt a state-management library and a component framework as the standard, so every page follows the same opinionated structure.Recommendation
For a new React 19 feature, apply the decision flowchart in order. If the UI shape varies by page or tenant, build it as composition — a layout with named slots and pages that pass the pieces. If logic repeats in two or more components, extract it into a named custom hook with one concern, and write the hook's test before the component's. If several related components share state, build the family as a compound component with narrow Context and an explicit error outside the parent. If the feature fetches data, fetch it in the Server Component and pass the result down; put 'use client' on the interactive leaf, never on the page. Enable the Compiler from the start and let the linter, not habit, decide whether memoization is needed.
For an existing codebase, the migration is one pattern at a time and each step is safe on its own. Replace one prop-drilling chain with a slot: the intermediate components lose props they never used, and their tests get shorter. Replace one duplicated effect with a hook: the call sites get shorter and the hook gets a test. Replace one prop-threaded family with a compound component: the parent owns the state and the children stop accepting props they only forward. Move one page's fetch from a client effect to its Server Component: the loading state disappears and the waterfall with it. Each replacement is a small, testable change, and the design gets visibly simpler with every one. For the same discipline applied to the services behind the frontend, our Hexagonal and Clean Architecture guide shows ports and adapters in Spring Boot, Node, and Python; for the design-pattern vocabulary these React patterns share, our Strategy and Template Method guide covers the same variation problems in three languages; and for the API the Server Components call, our REST vs GraphQL vs gRPC guide is the decision to make before the frontend patterns matter at all.
When NOT to use these patterns
usePageLogic hides the logic it claims to organise. A hook earns its name by being reused or by naming a real concern; a single-use effect with a clear comment is better than a single-use hook with a vague name.useMemo with a stale dependency array is a bug the compiler would not have written, and a memo wrapper on a component the compiler already memoizes is dead code that misleads the next reader. Keep the escape hatches for the cases the compiler cannot see, and document why each one exists.'use client' on a page. The directive applies to the whole module, so one interactive leaf turns the page and everything it imports into client code. Move the directive to the leaf, pass Server Components down as children, and keep the boundary visible in the file tree.Composition, custom hooks, compound components, and the Server/Client split survive because they name the four ways a React app varies — shape, logic, shared state, and where code runs — and naming the variation is what lets a team extend the app without breaking what already works. The patterns are small — a slot, a named function, a context, a boundary — and their value is entirely in the discipline around them: the seam is visible, the hook has one concern, the context is narrow, and the boundary is drawn once.
Why This Matters
Understanding the business and technical context helps you make informed decisions rather than blindly following patterns.
Trade-offs to Consider
Every architectural decision involves trade-offs. Consider your specific requirements, team expertise, and scale when evaluating options.
When NOT to Use This
Knowing when a solution doesn't apply is as valuable as knowing when it does. Consider alternatives for your specific situation.
Decision Framework
Use this framework to evaluate whether this approach is right for your use case based on your specific constraints and requirements.