Skip to main content

What is a "presentational component"?

Short definition

A presentational component is a component that is responsible only for the appearance (UI) and contains no business logic or application state.

In other words:

This is a "dumb" component that simply receives data via props and renders it as JSX.


Difference from a container component

CharacteristicPresentational (UI)Container (Logic)
Main taskDisplaying dataManaging data
Where data is storedIn propsIn state, context, or the store
StateAlmost neverUsually present
Logic (fetch, filters, handlers)NoYes
Connection to the serverNoYes
ReusabilityVery highLimited by context
ExampleUserCard, Button, HeaderUserContainer, ProductsContainer

Example 1. A simple presentational component

javascript
function UserCard({ name, email }) { return ( <div className="user-card"> <h3>{name}</h3> <p>{email}</p> </div> ); }

Features:

  • No state (useState).
  • No side effects (useEffect).
  • Only displays data.
  • Receives everything via props.

Usage:

javascript
<UserCard name="Tim" email="tim@example.com" />

Example 2. Separating the container from the presentational component

javascript
function UserContainer() { const [user, setUser] = useState(null); useEffect(() => { fetch("/api/user") .then(res => res.json()) .then(setUser); }, []); if (!user) return <p>Loading...</p>; return <UserCard name={user.name} email={user.email} />; }

Here:

  • UserContainer -> logic (fetch, state);
  • UserCard -> presentation (markup, styles).

This separation keeps the code clean and reusable.


Example 3. A presentational component with children

javascript
function Card({ title, children }) { return ( <div className="card"> <h2>{title}</h2> <div>{children}</div> </div> ); }

Usage:

javascript
<Card title="Profile"> <UserCard name="Anya" email="anya@example.com" /> </Card>

The Card component doesn't know exactly what's inside; it's simply responsible for the structure and style.


Example 4. A presentational component as a UI library

Most UI components (for example, from shadcn/ui, Material UI, Chakra UI) are presentational components.

Examples:

javascript
<Button variant="primary">Submit</Button> <Alert type="error">Error!</Alert> <Modal isOpen>Content</Modal>

None of them manage data state; they simply render what was passed to them.


Example 5. Minimal logic inside

Sometimes minimal UI logic is allowed, for example:

  • highlighting the selected element;
  • toggling classes;
  • local UI effects (hover, active, collapse, etc.).
javascript
function ToggleButton({ active, label }) { return ( <button className={active ? "btn-active" : "btn"}> {label} </button> ); }

This is still "presentational": no state, just a reaction to props.


Why this approach matters

Separation of concerns: logic is separate, presentation is separate.

Reusability: the same UI component can be used in different places.

Easy testing: you can simply verify that it renders the correct JSX for the data.

Clean code: presentational components do not "weigh down" the application's logic.


Summary

What it isA component that only displays data
Where it stores dataIn props
Has stateNo (almost never)
Where it's usedInside container or other UI components
What it containsJSX, styles, children
Main goalSeparate the visual part from the logical part

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.