presentational-container-pattern

Separates React data-fetching logic from UI rendering using container and presentational components.

1|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/TierOne-Studio/spa-velocity --skill presentational-container-pattern-tierone-studio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: presentational-container-pattern
Source: https://github.com/TierOne-Studio/spa-velocity/tree/main/.ruler/skills/presentational-container-pattern
Command: npx skills add https://github.com/TierOne-Studio/spa-velocity --skill presentational-container-pattern-tierone-studio

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? React components often mix data fetching, state management, and rendering in one file, making them hard to test, reuse, and maintain. This Skill teaches the Container/Presentational pattern to enforce a clean separation of concerns between application logic and the view. ## Core Features & Use Cases - Separation of Concerns: Container components handle data fetching and state while presentational components render data received through props. - Reusable, Testable UI: Presentational components are pure functions that can be reused across the app and tested without mocking data stores. - Hooks Alternative: Explains when a custom Hook (e.g., useDogImages) replaces the container component for the same separation with less boilerplate. - Use Case: When building a feature that fetches dog images from an API and renders them, split the work into a DogImagesContainer (fetching) and a DogImages presentational component (rendering), or extract the fetching into a custom Hook. ## Quick Start Refactor my React component so the API data fetching lives in a container or custom Hook and the JSX rendering stays in a pure presentational component.

Frequently Asked Questions about presentational-container-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is the Container/Presentational pattern in React?

The Container/Presentational pattern splits a feature into two parts: container components that fetch data and manage state, and presentational components that only render data received through props. This enforces separation of concerns between application logic and the view.

How do I separate data fetching from rendering in React?

Move data fetching and state into a container component or a custom Hook, and keep the rendering in a pure presentational component that receives data via props. The presentational component should not modify the data it receives.

Container/Presentational pattern vs custom Hooks: which should I use?

Custom Hooks are generally preferred in modern React because they achieve the same separation of logic and view without an extra wrapper component. The Container/Presentational pattern is still valid but can be overkill when a Hook like useDogImages encapsulates the data logic.

When should I not use the Container/Presentational pattern?

Avoid it for small components where splitting into two files adds overhead without benefit, for one-off views with no reuse potential, and when a custom Hook already encapsulates the data logic, making a separate container redundant.

Why are presentational components easier to test?

Presentational components are usually pure functions that render based solely on the props they receive. Tests can assert the rendered output for given props without mocking data stores, APIs, or application state.