All articles

Front-end12 min read

Smart and dumb components in Angular and React, in 2026

What separates smart and dumb components, the same example in Angular 22 and React 19, what the pattern's own author revisited and when the split still pays off.

Also in Português, Español, Français

"Smart and dumb components" is one of those topics that shows up in interviews, in code review and in every front-end architecture discussion. Sometimes under another name: container and presentational. The idea is simple, but a lot has changed since it got famous, and if you learned it in 2016 you're probably still applying it the old way.

This post explains the split, shows the same example in Angular and React the way each one does it today, and tells a part few people know: the author of the article that made the pattern popular in React wrote, years later, that he no longer recommends splitting components like this.

An honest note: the examples were compiled and tested on Angular 22.3 and React 19.3. Each one has a test that loads the orders, filters and selects one, and both pass.

TL;DR#

  • Smart knows where the data comes from and decides what to do with it. Dumb gets everything through input or props and only reports, through an event, that something happened.
  • In Angular, the split fits very well: input(), output() and model() in the dumb one, httpResource and computed in the smart one. Since version 22, OnPush is the default.
  • In React, the "smart" part today is usually a hook, not a container component. Dan Abramov himself revised his article in 2019 to say so.
  • With Server Components, the split came back in a new form: the server component fetches the data, the client component handles the interaction.
  • Don't split out of dogma. Split when the data logic gets in the way of reading the screen or when the visual component needs to be reused.

What each one is#

Smart (container)Dumb (presentational)
Datafetches from the API, service or storegets everything through input or props
Decisionsdecides what happens on a clickonly reports the click
Statescreen state (filter, selection, loading)at most visual state (open, closed)
Dependenciesservices, HTTP, routernone, besides other visual components
Reusealmost none, it's the screen's gluehigh, works on any screen
Testingneeds to fake the APIpass data in, check the HTML

Notice the state row: a dumb component can have state, as long as it's UI state, like a menu being open or closed. What it can't do is know where the data comes from or what to do with it.

Why split#

  • The visual component becomes reusable. An order card that only receives an order works in the list, in the detail page, in an email preview.
  • Testing gets cheap. To test the dumb one, you pass data and check the HTML. No API to fake, no fake service.
  • Changing the data source doesn't touch the screen. If the API changes, or data starts coming from a cache, only the smart one changes.
  • It's clear who's in charge. Data goes down through input or props, events go up. When something breaks, you know where to look.

The example: an order list#

Both examples build the same screen: a list of orders with a status filter and selection of one order.

Only one component knows where the data comes from. The others receive and report
  • OrdersPage (smart): fetches the orders, holds the filter and which order is selected.
  • StatusFilter (dumb): shows the status buttons and reports when it changes.
  • OrderList (dumb): draws the list or the empty message.
  • OrderCard (dumb): draws one order and reports when "Details" is clicked.

The model is the same in both:

order.ts
export type OrderStatus = 'pending' | 'paid' | 'shipped';
 
export interface Order {
  id: string;
  customer: string;
  total: number;
  status: OrderStatus;
}

In Angular#

The card (dumb)#

order-card.ts
import { CurrencyPipe } from '@angular/common';
import { Component, input, output } from '@angular/core';
import { Order } from './order';
 
@Component({
  selector: 'app-order-card',
  imports: [CurrencyPipe],
  template: `
    <article class="card" [class.selected]="selected()">
      <h3>{{ order().customer }}</h3>
      <p>{{ order().total | currency: 'BRL' }} · {{ order().status }}</p>
      <button type="button" (click)="orderSelected.emit(order().id)">Details</button>
    </article>
  `,
})
export class OrderCard {
  readonly order = input.required<Order>();
  readonly selected = input(false);
  readonly orderSelected = output<string>();
}
  • input.required<Order>() forces whoever uses the component to pass the order. If they forget, the error shows up at build time, not in production.
  • input(false) is an optional input with a default value.
  • output<string>() is the event. The component only emits the id and doesn't know what happens next.
  • readonly on inputs and outputs is a recommendation from the Angular style guide: it stops anyone from overwriting what Angular fills in.

A naming detail: the event is called orderSelected, not select. The Angular guide asks you to avoid names that collide with DOM events, and select is one of them.

The list and the filter (dumb)#

order-list.ts
import { Component, input, output } from '@angular/core';
import { Order } from './order';
import { OrderCard } from './order-card';
 
@Component({
  selector: 'app-order-list',
  imports: [OrderCard],
  template: `
    @for (order of orders(); track order.id) {
      <app-order-card
        [order]="order"
        [selected]="order.id === selectedId()"
        (orderSelected)="orderSelected.emit($event)"
      />
    } @empty {
      <p class="empty">No orders here yet.</p>
    }
  `,
})
export class OrderList {
  readonly orders = input.required<Order[]>();
  readonly selectedId = input<string | null>(null);
  readonly orderSelected = output<string>();
}

The list decides nothing: it receives the orders, marks the selected one and passes the event up. @empty handles the empty state without an extra @if.

status-filter.ts
import { Component, model } from '@angular/core';
import { OrderStatus } from './order';
 
export type StatusFilterValue = OrderStatus | 'all';
 
@Component({
  selector: 'app-status-filter',
  template: `
    @for (option of options; track option) {
      <button type="button" [class.active]="option === status()" (click)="status.set(option)">
        {{ option }}
      </button>
    }
  `,
})
export class StatusFilter {
  readonly status = model<StatusFilterValue>('all');
  protected readonly options: StatusFilterValue[] = ['all', 'pending', 'paid', 'shipped'];
}

The filter uses model(), an input that the component itself can also change. From the outside, the user binds both ways with [(status)]. It's Angular's way of doing the "value plus change event" pair in a single line.

The page (smart)#

orders-page.ts
import { httpResource } from '@angular/common/http';
import { Component, computed, signal } from '@angular/core';
import { Order } from './order';
import { OrderList } from './order-list';
import { StatusFilter, StatusFilterValue } from './status-filter';
 
@Component({
  selector: 'app-orders-page',
  imports: [OrderList, StatusFilter],
  template: `
    <h2>Orders</h2>
    <app-status-filter [(status)]="status" />
 
    @if (orders.isLoading()) {
      <p>Loading orders...</p>
    } @else if (orders.error()) {
      <p>Could not load the orders.</p>
    } @else {
      <app-order-list
        [orders]="visibleOrders()"
        [selectedId]="selectedId()"
        (orderSelected)="selectedId.set($event)"
      />
    }
  `,
})
export class OrdersPage {
  protected readonly status = signal<StatusFilterValue>('all');
  protected readonly selectedId = signal<string | null>(null);
  protected readonly orders = httpResource<Order[]>(() => '/api/orders', { defaultValue: [] });
 
  protected readonly visibleOrders = computed(() => {
    const status = this.status();
    const orders = this.orders.value();
    return status === 'all' ? orders : orders.filter((order) => order.status === status);
  });
}
  • httpResource makes the HTTP call and exposes value(), isLoading() and error() as signals. It's a stable API since Angular 22. It needs provideHttpClient() in the application config.
  • computed derives the filtered list from the filter and the orders. Change the filter, the list recalculates on its own.
  • protected on members used only in the template is another style guide recommendation: they're not part of the component's public API.

And what was left out matters too: no dumb component imports HttpClient, a service or the router. If tomorrow the orders come from a WebSocket, only OrdersPage changes.

What about OnPush?#

For years the advice was "put ChangeDetectionStrategy.OnPush on dumb components", so Angular would only check them when their inputs changed. In Angular 22, OnPush became the default, and the old strategy, now called Eager, is the one you have to ask for. That's why the examples above don't declare anything. In projects on older versions, the advice still applies.

When the logic is shared#

If two screens need the same orders, move the httpResource and the state out of the component into a service with @Injectable({ providedIn: 'root' }). The page stays smart, but thin: it just does inject(OrdersStore) and wires the data into the dumb components.

In React#

The visual components (dumb)#

OrderCard.tsx
import type { Order } from './order';
 
interface OrderCardProps {
  order: Order;
  selected?: boolean;
  onSelect: (id: string) => void;
}
 
const brl = new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' });
 
export function OrderCard({ order, selected = false, onSelect }: OrderCardProps) {
  return (
    <article className={selected ? 'card selected' : 'card'}>
      <h3>{order.customer}</h3>
      <p>{brl.format(order.total)} · {order.status}</p>
      <button type="button" onClick={() => onSelect(order.id)}>Details</button>
    </article>
  );
}
OrderList.tsx
import type { Order } from './order';
import { OrderCard } from './OrderCard';
 
interface OrderListProps {
  orders: Order[];
  selectedId: string | null;
  onSelect: (id: string) => void;
}
 
export function OrderList({ orders, selectedId, onSelect }: OrderListProps) {
  if (orders.length === 0) return <p className="empty">No orders here yet.</p>;
 
  return orders.map((order) => (
    <OrderCard key={order.id} order={order} selected={order.id === selectedId} onSelect={onSelect} />
  ));
}
StatusFilter.tsx
import type { OrderStatus } from './order';
 
export type StatusFilterValue = OrderStatus | 'all';
 
const OPTIONS: StatusFilterValue[] = ['all', 'pending', 'paid', 'shipped'];
 
interface StatusFilterProps {
  value: StatusFilterValue;
  onChange: (value: StatusFilterValue) => void;
}
 
export function StatusFilter({ value, onChange }: StatusFilterProps) {
  return OPTIONS.map((option) => (
    <button key={option} type="button" className={option === value ? 'active' : undefined} onClick={() => onChange(option)}>
      {option}
    </button>
  ));
}

In React, the role of output is played by a function passed through props. The convention is to name it on + action (onSelect, onChange). The role of model() is the value and onChange pair.

The page (smart)#

useOrders.ts
import { useEffect, useState } from 'react';
import type { Order } from './order';
 
type LoadState = 'loading' | 'ready' | 'error';
 
export function useOrders() {
  const [orders, setOrders] = useState<Order[]>([]);
  const [state, setState] = useState<LoadState>('loading');
 
  useEffect(() => {
    const controller = new AbortController();
    fetch('/api/orders', { signal: controller.signal })
      .then((response) => {
        if (!response.ok) throw new Error(`HTTP ${response.status}`);
        return response.json() as Promise<Order[]>;
      })
      .then((data) => {
        setOrders(data);
        setState('ready');
      })
      .catch(() => {
        if (!controller.signal.aborted) setState('error');
      });
    return () => controller.abort();
  }, []);
 
  return { orders, state };
}
OrdersPage.tsx
import { useState } from 'react';
import { OrderList } from './OrderList';
import { StatusFilter, type StatusFilterValue } from './StatusFilter';
import { useOrders } from './useOrders';
 
export function OrdersPage() {
  const { orders, state } = useOrders();
  const [status, setStatus] = useState<StatusFilterValue>('all');
  const [selectedId, setSelectedId] = useState<string | null>(null);
 
  const visibleOrders = status === 'all' ? orders : orders.filter((order) => order.status === status);
 
  return (
    <>
      <h2>Orders</h2>
      <StatusFilter value={status} onChange={setStatus} />
      {state === 'loading' && <p>Loading orders...</p>}
      {state === 'error' && <p>Could not load the orders.</p>}
      {state === 'ready' && <OrderList orders={visibleOrders} selectedId={selectedId} onSelect={setSelectedId} />}
    </>
  );
}

A note on useOrders: fetching data with useEffect works and keeps the example short, but the React documentation itself recommends, in a real app, using your framework's data fetching or a library with a cache. The smart and dumb split doesn't change with that: only what's inside the hook changes.

What the pattern's author revisited#

The article that made the split popular in React is "Presentational and Container Components", by Dan Abramov, from 2015. In 2019 he added a note at the top: "I don't suggest splitting your components like this anymore". His explanation, in short: what he liked most about the split was separating stateful logic from the rest of the component, and hooks do that without forcing you to create an extra component. He also says he saw the pattern enforced without need, almost like a religious rule.

In practice, that changes the design:

  • The smart part became the hook. useOrders holds the fetching and the loading state. Any component that needs the orders calls the hook, with no container in between.
  • Dumb components are still great. OrderCard and OrderList keep getting everything through props, and that's what makes them easy to test and reuse.
  • The container became optional. OrdersPage still exists because it's the screen, not because the pattern says so.

Server Components: the split is back#

With React Server Components (in a framework that supports them, like the Next.js App Router), the split shows up again, now by where the code runs:

orders-page.tsx
import type { Order } from '../order';
import { OrdersView } from './orders-view';
 
async function getOrders(): Promise<Order[]> {
  const response = await fetch('https://api.example.com/orders', { cache: 'no-store' });
  if (!response.ok) throw new Error(`HTTP ${response.status}`);
  return response.json();
}
 
// Server Component: runs on the server, fetches the data and never ships this code to the browser.
export default async function OrdersPage() {
  const orders = await getOrders();
  return <OrdersView orders={orders} />;
}
orders-view.tsx
'use client';
 
import { useState } from 'react';
import type { Order } from '../order';
import { OrderList } from '../OrderList';
import { StatusFilter, type StatusFilterValue } from '../StatusFilter';
 
// Client Component: receives the data as props and handles the interaction.
export function OrdersView({ orders }: { orders: Order[] }) {
  const [status, setStatus] = useState<StatusFilterValue>('all');
  const [selectedId, setSelectedId] = useState<string | null>(null);
  const visibleOrders = status === 'all' ? orders : orders.filter((order) => order.status === status);
 
  return (
    <>
      <StatusFilter value={status} onChange={setStatus} />
      <OrderList orders={visibleOrders} selectedId={selectedId} onSelect={setSelectedId} />
    </>
  );
}

The server component is the smart one: it fetches the data close to the database, and its code never even reaches the browser. The component with 'use client' handles the filter and the selection, and the dumb ones are the same as before.

Angular and React side by side#

IdeaAngular 22React 19
Receive datainput() / input.required()props
Notify the parentoutput() + .emit()function through props (onSelect)
Two-way valuemodel() + [(value)]value + onChange
Fetch datahttpResource or a service with inject()hook, framework fetching or Server Component
Derive datacomputed()plain calculation in render
List@for (...; track id).map() with key
Empty list@emptyif before the map
Avoid needless rendersOnPush, default since v22memo or the React Compiler

Common mistakes#

  • The dumb one that injects "just a little service". A single inject(HttpClient) or a fetch inside the card is enough to make it no longer reusable. If it needs data, it gets it through input.
  • The smart one that becomes a god. A page with 600 lines of logic didn't improve anything. Move the logic to a service (Angular) or a hook (React) and let the page just wire the pieces.
  • Five levels of prop drilling. Passing the same data through four components that don't use it is a sign that one further down could be smart, or that the data deserves a service (Angular) or a context (React).
  • Thinking dumb can't have state. Visual state, like an open accordion, lives in the component itself. What doesn't live there is business data.
  • Event names that match DOM events. select, change and click confuse whoever reads the template. Prefer orderSelected, statusChange.
  • Splitting everything by rule. A small component that fetches and shows three lines doesn't need to become two files.

When it's worth it#

My recommendation:

  • Always split out visual components that show up on more than one screen. They should get everything through input or props.
  • Almost always keep data fetching and screen state in one place: the page, a service or a hook.
  • In React, prefer a hook over a container component. Create the container only when it really is the screen.
  • In Angular, the split comes almost for free with signals. Use it, but don't create a component just to "follow the pattern".
  • Don't split small components used only once. Separation has a reading cost too.

Checklist#

  • Visual components receive data only through input or props.
  • Visual components notify the parent through output or an on... function, without deciding what happens.
  • No visual component imports HTTP, a data service or the router.
  • Data fetching and screen state in one place (page, service or hook).
  • In Angular: input.required for what's mandatory, readonly on inputs and outputs, protected on what's template-only.
  • In React: stateful logic in hooks, on... props for events.
  • Event names that don't collide with DOM events.
  • Nothing split just because of a rule.

References#

  • Front-end
  • angular
  • react
  • components
  • architecture
  • signals

Written by

Software engineer and designer. I write about what I run into while building apps, APIs and products.

Comments

Sign in with your GitHub account to comment.