Brains vs. Beauty: Smart and Dumb Components in React
Separate logic-heavy “smart” components from visual-only “dumb” components. This boosts reuse, readability, and collaboration across teams. Works best in larger apps with shared design systems.
- Technology
- 2 min read
Think of a movie set 🎬 — the director handles the story, camera angles, and actors (brains), while the actors just deliver their lines and look good on screen (beauty).
That’s exactly the relationship between Smart (container) components and Dumb (presentational) components in React.
Core Idea
- Smart Components (Brains) → Handle data fetching, state management, and logic.
- Dumb Components (Beauty) → Focus purely on how things look (UI markup + styling).
👉 Separating the two keeps apps clean, reusable, and scalable.
Basics & Need
- Without separation, components become bloated (too much logic + too much UI).
- Maintenance becomes harder as apps grow.
- This pattern enforces separation of concerns:
- Smart = business logic.
- Dumb = presentation.
How to Achieve It
Example 1: Splitting Components
// Dumb Component (UI Only)const UserListView = ({ users }) => (<ul>
{users.map((u) => (<li key={u.id}>{u.name}</li>
))}</ul>
);// Smart Component (Logic)const UserListContainer = () => {const [users, setUsers] = React.useState([]);React.useEffect(() =>{fetch("/api/users").then((res) => res.json()).then(setUsers);
}, []);return <UserListView users={users}/>;
};
👉 UserListContainer fetches and prepares the data, while UserListView only displays it.
Example 2: Button Example
// Dumbconst Button = ({ label, onClick }) => <button onClick={onClick}>{label}</button>;// Smartconst SaveButton = () => {const handleSave = () => console.log("Data saved!");return <Button label="Save" onClick={handleSave}/>;
};
Best Practices
✅ Keep dumb components stateless and focused on UI.
✅ Smart components manage state, data fetching, and pass props down.
✅ Make dumb components reusable across apps.
❌ Don’t overload smart components with both logic + UI.
Real-World Examples
- User Profile Page → Smart component fetches profile data, Dumb displays avatar and info.
- E-commerce Cart → Smart calculates totals, Dumb renders items list and buttons.
- Search Box → Smart manages queries, Dumb renders input field + button.
Advantages
✔ Cleaner separation of concerns.
✔ Easier to test UI and logic independently.
✔ Dumb components are highly reusable.
✔ Improves maintainability in large apps.
Disadvantages
⚠ Extra boilerplate (more files/components).
⚠ May feel too rigid for smaller projects.
⚠ Lines blur in modern React with hooks (many devs merge logic + UI).
Common Problems / Pitfalls
- Over-separating → too many unnecessary files.
- Dumb components leaking logic → breaks the separation.
- Smart components growing into “god components” if not managed well.
Summary Recommendation
🎯 Use the Smart vs. Dumb Component pattern to clearly separate logic from UI. Best suited for medium to large apps where maintainability and reusability matter. For smaller apps, feel free to mix, but when scaling — let Brains handle the logic and Beauty handle the looks.