<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Konrad Gawryluk</title>
    <description>The latest articles on DEV Community by Konrad Gawryluk (@konradgawryluk).</description>
    <link>https://dev.to/konradgawryluk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F967999%2Fb146b27a-a501-464b-ae41-54b58be0ae97.png</url>
      <title>DEV Community: Konrad Gawryluk</title>
      <link>https://dev.to/konradgawryluk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/konradgawryluk"/>
    <language>en</language>
    <item>
      <title>The Power of Dumb Components in Scalable React Apps</title>
      <dc:creator>Konrad Gawryluk</dc:creator>
      <pubDate>Sat, 24 May 2025 09:41:17 +0000</pubDate>
      <link>https://dev.to/konradgawryluk/the-power-of-dumb-components-in-scalable-react-apps-4poa</link>
      <guid>https://dev.to/konradgawryluk/the-power-of-dumb-components-in-scalable-react-apps-4poa</guid>
      <description>&lt;p&gt;If I had to choose just one principle to help frontend developers write better React code, it would be this: &lt;strong&gt;use dumb components&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This approach is often underestimated or used only for shared UI libraries. But in my experience, applying it regularly — even in app-specific parts — always makes the code cleaner and easier to manage.&lt;/p&gt;

&lt;p&gt;Let’s dive into what this means in practice.&lt;/p&gt;

&lt;h3&gt;
  
  
  ✅ What Are Dumb Components?
&lt;/h3&gt;

&lt;p&gt;Dumb components — also called &lt;strong&gt;presentational components&lt;/strong&gt; — focus only on how things look. They are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Not responsible for business logic or application-level state.&lt;/li&gt;
&lt;li&gt;Driven entirely by &lt;strong&gt;props&lt;/strong&gt; — they receive all data and event handlers from the outside.&lt;/li&gt;
&lt;li&gt;Allowed to use &lt;strong&gt;local state&lt;/strong&gt;, but only for things related to presentation (e.g. toggling a tooltip).&lt;/li&gt;
&lt;li&gt;Allowed to use &lt;strong&gt;context&lt;/strong&gt; (like theming or localization), as long as it's not about application logic (like auth or cart data).
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;UserCardProps&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;avatarUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;UserCard&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;avatarUrl&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;UserCardProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"user-card"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;avatarUrl&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;alt&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;'s avatar`&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because they don’t handle logic, dumb components are easy to reuse, test, and understand.&lt;/p&gt;

&lt;h3&gt;
  
  
  🤔 What’s a Smart Component Then?
&lt;/h3&gt;

&lt;p&gt;Smart components (also known as container components) are in charge of everything else:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fetching and preparing data&lt;/li&gt;
&lt;li&gt;Managing state with hooks like &lt;code&gt;useState&lt;/code&gt; or &lt;code&gt;useReducer&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Handling business logic and user actions&lt;/li&gt;
&lt;li&gt;Connecting to app-level context or external stores
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;UserCardContainer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useUser&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// gets user data from context or API&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;UserCard&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;avatarUrl&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;avatarUrl&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Smart components do the heavy lifting, while dumb components focus only on rendering the UI.&lt;/p&gt;

&lt;h3&gt;
  
  
  👍 Why Dumb Components Are Great
&lt;/h3&gt;

&lt;p&gt;Here’s why using dumb components makes a big difference:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🧩 &lt;strong&gt;Modular&lt;/strong&gt; – each one has a clear and simple job&lt;/li&gt;
&lt;li&gt;🔄 &lt;strong&gt;Reusable&lt;/strong&gt; – works with different data without changes&lt;/li&gt;
&lt;li&gt;🧪 &lt;strong&gt;Testable&lt;/strong&gt; – no side effects, easy to write unit tests&lt;/li&gt;
&lt;li&gt;🧠 &lt;strong&gt;Predictable&lt;/strong&gt; – just look at the props to know how it works&lt;/li&gt;
&lt;li&gt;👩‍💻 &lt;strong&gt;Maintainable&lt;/strong&gt; – logic and UI are cleanly separated&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When your codebase grows, this structure helps keep things organized and easier to change.&lt;/p&gt;

&lt;h3&gt;
  
  
  🛠️ When to Extract Dumb Components
&lt;/h3&gt;

&lt;p&gt;There are two common cases where you should create dumb components:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Move logic &lt;em&gt;up&lt;/em&gt; from a visual component
&lt;/h4&gt;

&lt;p&gt;Sometimes you’ll notice multiple components each handling their own piece of state — but those pieces are connected. Instead of spreading logic around, move it up into one place, and pass the needed data and callbacks down as props.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🔍 &lt;strong&gt;Tip&lt;/strong&gt;: This is especially useful when working in legacy codebases where logic and UI are mixed together.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  2. Move visual parts &lt;em&gt;out&lt;/em&gt; of a large smart component
&lt;/h4&gt;

&lt;p&gt;It’s common to build everything in one big component at first. But when you notice that part of the JSX is just layout or display, it’s time to extract it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This makes the smart component easier to understand, and the new dumb component easier to reuse elsewhere.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  ⚠️ Common Misconceptions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;❌ &lt;em&gt;“Dumb components can’t use &lt;code&gt;useState&lt;/code&gt;”&lt;/em&gt;&lt;br&gt;
✅ They &lt;strong&gt;can&lt;/strong&gt;, as long as the state is only used for UI, not for app logic.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;❌ &lt;em&gt;“Using context makes a component smart”&lt;/em&gt;&lt;br&gt;
✅ Not always. If you use context just for themes or translations, it’s still presentational.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🧠 Bonus: Why This Matters Long-Term
&lt;/h3&gt;

&lt;p&gt;In larger apps or teams, this pattern brings big advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Scalable structure&lt;/strong&gt; – clear separation between logic and UI&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Better collaboration&lt;/strong&gt; – easier to split work between devs and designers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Smaller Git diffs&lt;/strong&gt; – changing logic doesn’t touch UI and vice versa&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Easier testing&lt;/strong&gt; – presentational components don’t need complex setup&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Safer refactoring&lt;/strong&gt; – you can change one side (logic or UI) without breaking the other&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This all leads to faster development and fewer bugs in the long run.&lt;/p&gt;

&lt;h3&gt;
  
  
  📚 Further Reading
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://reactjs.org/docs/thinking-in-react.html" rel="noopener noreferrer"&gt;React Docs – Thinking in Components&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kentcdodds.com/blog/application-state-management-with-react" rel="noopener noreferrer"&gt;Kent C. Dodds – Application State Management&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ✅ Final Thoughts
&lt;/h3&gt;

&lt;p&gt;Dumb components are a simple idea, but they can seriously improve the way you build React apps.&lt;/p&gt;

&lt;p&gt;They help you separate responsibilities, make your code easier to test and reuse, and keep things clean even as your app grows.&lt;/p&gt;

&lt;p&gt;Start small — look for parts of your code that only handle display, and move them into their own components. You’ll quickly see the benefits.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>cleancode</category>
    </item>
  </channel>
</rss>
