All topics
Patternsbeginner

Container/Presentational Component Split

Learn the classic pattern of separating data-fetching and logic (containers) from pure rendering (presentational components).

The container/presentational split organizes components into two categories: container components that handle data fetching, state, and business logic, and presentational components that receive fully-formed data via props and focus purely on rendering markup and styling, with no awareness of where their data came from.

It's like a restaurant kitchen (container) handling sourcing, cooking, and plating logic, versus the dining room server (presentational component) whose only job is to present the finished plate attractively to the guest — the server doesn't need to know which supplier the vegetables came from to do their job well.

Key Concepts

1
This separation makes presentational components highly reusable and easy to test in isolation — since they're pure functions of their props, you can render them with mock data in a test or a Storybook story without needing to stub out API calls or context providers. Containers, meanwhile, concentrate the messier logic (fetching, subscribing, transforming) in one place per feature.
2
With the rise of hooks, this pattern has softened somewhat: custom hooks can extract the 'container' logic into a reusable function without requiring a literal separate container *component*, letting a single component call useUserData() and render presentational JSX itself, blurring what used to be a hard architectural line. Many modern codebases use a lighter version of this idea — 'smart' data-fetching hooks paired with 'dumb' rendering components — rather than a strict two-file container/presentational file pair for every feature.
useUserData()
3
Interviewers ask about this pattern to see if a candidate can articulate the underlying principle (separating data concerns from rendering concerns) even if the specific literal 'Container.js/Presentational.js' file convention has fallen out of fashion in favor of hooks-based equivalents.