skip to content

Component Architecture at Scale

Cutting a large UI into containers and presentational parts, headless and styled layers, and props contracts that stay stable. Interviewers check whether the structure survives the tenth feature.

on this pageshow

questions

5

In a B2B web admin console's orders screen — grid, filter bar, bulk-actions bar, side panel — which components should own data, and which only render?

level: middleimportance: must knowfreq 58%

answer

  1. who else reads this value
  2. nearest common owner
  3. decide versus draw
  4. panel fetches by selected ID
  5. UI-only state may stay local

basics

~20 s

A few region-level owners hold the data: the orders page owns filters, sort, selection and the list query, and a side-panel container fetches the selected order. The grid, filter bar, bulk-actions bar and panel body only render inputs and report intent.

solid answer

~50 s

I'd draw the tree first. `OrdersPage` owns the list query keyed by filters and sort, the selection set and the bulk mutations. `FilterBar`, `OrdersGrid` and `BulkActionsBar` receive values and report intent through callbacks such as `onFiltersChange`, `onSortChange`, `onSelectionChange` and `onBulkAction`; none of them fetches. The side panel gets its own small container that takes `selectedOrderId` and fetches that order, so the list payload stays lean and the panel loads on its own. The test for every value is *who else needs it*: shared values live with the nearest common owner, and UI-only state such as an open row menu stays inside the part that draws it. Whether an owner is a separate container component or a reusable stateful logic unit called from the page is secondary; the line that matters is between deciding and drawing.

code

pseudocode · 7 lines
pseudocode
OrdersPage                      owns: filters, sort, selectedIds, list query, bulk mutations
  FilterBar(filters, onFiltersChange)
  BulkActionsBar(count = size(selectedIds), onBulkAction)
  OrdersGrid(rows, sort, selectedIds, onSortChange, onSelectionChange)
      owns privately: open row menu, column resize drag, focused cell
  OrderPanelContainer(orderId = activeOrderId)   owns: fetch of one order
    OrderPanelBody(order)

go deeper

for a junior

Recall the two roles: parts that decide what data is shown and parts that only show what they receive. Be ready to point at one of each on the orders screen.

for a middle

Walk the screen region by region and place each value with its nearest common reader. Explain why the side panel gets its own small data owner instead of riding on the list query.

for a senior

Show where the split pays off and where it is ceremony: reuse across screens, isolated tests and design review versus a one-off region. Name the failure of a single god container and of self-fetching widgets.

for a principal

Frame it as a team convention: what every feature's screen must separate, what form that takes is left to the team, and how reviewers recognise a rendering part that has started deciding business rules.

## What this part of the round is testing Once the requirements are agreed, the interviewer wants to see the **client's** architecture: the boxes on the screen, what each one is responsible for, and which data belongs to which box. For an orders screen in a B2B web admin console, the regions are easy to name — a **filter bar**, an **orders grid** with sorting and row selection, a **bulk-actions bar** that appears when rows are selected, and a **side panel** showing the selected order. The interesting part is not naming them; it is deciding which of them **own data** (fetch it, hold it, change it) and which only **render** what they are given. ## Step 1: list the regions and what each needs | Region | Renders | Needs from elsewhere | Owns data? | |---|---|---|---| | Orders page | layout only | the route | yes: list query, filters, sort, selection, bulk mutations | | Filter bar | filter controls | current filter values | no: reports changes upward | | Orders grid | rows, headers, checkboxes | rows, sort, selected IDs | no: reports sort and selection changes | | Bulk-actions bar | count and action buttons | selected IDs | no: reports which action was chosen | | Side panel container | nothing itself | the selected order ID | yes: fetches that order's details | | Side panel body | the order's details | the fetched order | no | The table makes the rule visible: **a value lives with the nearest part that every reader shares**. The filter values are read by the filter bar and by the list query, so they cannot live inside either one. The selection is read by the grid, the bulk-actions bar and the side panel, so the page holds it. ## Step 2: data owners and rendering parts The **container / presentational** split names exactly this division. A **presentational component** receives its data from its parent and displays it without modifying it; a **container component** decides *what* data is shown — fetching it, holding it and passing it down. The benefits are concrete: - rendering parts are easy to reuse, because they do not care where the rows came from; - they are easy to test, because the output depends only on the inputs, with no server or data layer to fake; - their appearance can change without touching the application logic. "Presentational" does not mean "no state at all". A rendering part may hold **UI-only state** — which row's action menu is open, a column being resized, hover — because nobody else needs it. What it does not do is fetch, own domain data, or decide business rules. Note that there is more than one data owner here. The side panel gets its own small container that takes the selected order ID and fetches that order. That keeps the grid's list payload lean (the list does not need every order's line items), lets the panel load and fail on its own, and lets the same panel open from a deep link to one order. ## Does the container layer still earn its keep? The pattern's own write-up notes that **reusable stateful logic units** — a function that encapsulates fetching and state and can be called from any component — can replace the container layer: the rendering component calls the unit and receives the data, and logic still stays out of the markup. It also notes the split can be overkill in a small application. So the honest answer is: 1. **Keep the separation always** — the decision about data never lives in the grid's rendering code. 2. **Choose the form per region.** A separate container component earns its keep where the same rendering part is fed from different sources (the orders grid on this page and on a customer's orders tab) or where you want to render it in isolation for tests and design review. 3. **Skip the extra wrapper** where a logic unit called by the page does the same job with one fewer component. ## Mistakes interviewers listen for - A grid that fetches its own rows, which hides the query from the filter bar and the bulk-actions bar. - One giant container that also owns menu-open flags and hover, so every trivial UI change flows through the screen's top owner and no part is reusable on its own. - Siblings reading each other's internal state through references instead of going through their common owner. - Treating "use a logic unit instead of a container" as "stop separating data from rendering".

  • Why not let the grid fetch its own rows?
    Because the filter bar, the bulk-actions bar and the result count all depend on the same query. A fetching grid hides the query inputs inside itself, so siblings either reach into it or duplicate it, and the grid can no longer be reused where rows come from a different query, such as one customer's orders tab. A grid that renders rows and reports sort changes works anywhere.
  • Must every presentational part be stateless?
    No. Rendering parts may keep UI-only state that nobody else reads: an open row menu, the focused cell, a column being resized. The rule is that they do not fetch, do not own domain data and do not alter the data they receive. Once a second part needs a value, it moves up to their common owner.
  • When would you not bother with separate containers?
    On a small screen with one data source and no reuse in sight, the extra wrapper buys little; a reusable stateful logic unit called by the page, or the page itself, can own the data. The separation still holds: rendering code does not fetch. The container component is one form of that separation, not the separation itself.

  • Every component should fetch its own data so it stays self-contained.
  • Presentational components may never hold any state, not even an open menu.
  • One top-level container should own all screen state, hover and menus included.
  • Reusable stateful logic units make separating data from rendering unnecessary.
  • Siblings can share values by reading each other's internal state through references.
open as a page

On a B2B admin console's orders grid, should sort, filters and row selection be owned by the grid, by the page, or by the URL?

level: middleimportance: should knowfreq 50%

basics

~20 s

Decide per value: sort and filters go in the URL because links, reload and Back must reproduce the view; the page holds the selection that the bulk-actions bar reads; open menus and focus stay inside the grid.

open as a page

In a B2B web console, an order-summary panel reused on checkout review, the order page and account history has grown eleven per-screen flags; what went wrong, and what would you change?

level: seniorimportance: should knowfreq 42%

basics

~20 s

The shared panel learned about its callers: teams added flags instead of composing, leaving untested combinations and no owner. Keep a core that renders lines and totals, and let each screen compose its own data mapping and actions.

open as a page

For a 40-engineer web admin console, how would you layer components from design-system primitives to pages, and where does the design system's edge sit?

level: seniorimportance: should knowfreq 38%

basics

~20 s

Four layers, imports pointing down: design-system primitives know no domain, app-shared composites know app conventions, feature components know their domain and data, pages own routes and the URL. Wrap the system for real defaults; never restyle its internals.

open as a page

In one web admin console codebase shared by five feature teams of 40 engineers, how would you draw feature-module seams and keep them from eroding?

level: principalimportance: should knowfreq 32%

basics

~20 s

Group code by feature, give each feature one public entry as its only importable surface, keep a small owned shared kernel, and enforce the seams with an import-boundary build rule whose baseline of old violations only shrinks.

open as a page