<?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: Mehrab Gholamsamani</title>
    <description>The latest articles on DEV Community by Mehrab Gholamsamani (@mehrabgholamsamani).</description>
    <link>https://dev.to/mehrabgholamsamani</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%2F3798151%2Fcf0d775a-2e75-4bca-993a-a5cfdf1d4596.jpeg</url>
      <title>DEV Community: Mehrab Gholamsamani</title>
      <link>https://dev.to/mehrabgholamsamani</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mehrabgholamsamani"/>
    <language>en</language>
    <item>
      <title>5 Mistakes I Avoided While Building a React and TypeScript Application</title>
      <dc:creator>Mehrab Gholamsamani</dc:creator>
      <pubDate>Sat, 28 Feb 2026 11:35:16 +0000</pubDate>
      <link>https://dev.to/mehrabgholamsamani/5-mistakes-i-avoided-while-building-a-react-and-typescript-application-40ha</link>
      <guid>https://dev.to/mehrabgholamsamani/5-mistakes-i-avoided-while-building-a-react-and-typescript-application-40ha</guid>
      <description>&lt;p&gt;When building React applications, most problems do not appear on day one.&lt;/p&gt;

&lt;p&gt;They show up weeks later.&lt;/p&gt;

&lt;p&gt;Components become harder to understand.&lt;br&gt;
State spreads everywhere.&lt;br&gt;
Performance slowly declines.&lt;/p&gt;

&lt;p&gt;I recently built a production ready React and TypeScript application, and instead of focusing only on features, I focused on avoiding common structural mistakes.&lt;/p&gt;

&lt;p&gt;Here are five mistakes I intentionally avoided and why they matter.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Putting API Calls Directly Inside Components
&lt;/h2&gt;

&lt;p&gt;It is very common to see something like this inside a component:&lt;/p&gt;

&lt;p&gt;You mount the component.&lt;br&gt;
You call fetch.&lt;br&gt;
You set state.&lt;/p&gt;

&lt;p&gt;It works.&lt;/p&gt;

&lt;p&gt;Until five components need similar logic.&lt;/p&gt;

&lt;p&gt;Instead, I created a dedicated API layer.&lt;/p&gt;

&lt;p&gt;Each endpoint had its own typed function.&lt;br&gt;
All requests were centralized.&lt;br&gt;
Error handling lived in one place.&lt;/p&gt;

&lt;p&gt;This gave me three advantages:&lt;/p&gt;

&lt;p&gt;Cleaner components&lt;br&gt;
Stronger type safety&lt;br&gt;
Easier refactoring&lt;/p&gt;

&lt;p&gt;Components became responsible for UI, not networking.&lt;/p&gt;

&lt;p&gt;That separation is small at first but huge later.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Overusing Global State Too Early
&lt;/h2&gt;

&lt;p&gt;It is tempting to introduce global state management immediately.&lt;/p&gt;

&lt;p&gt;But global state spreads like ink in water.&lt;/p&gt;

&lt;p&gt;I followed a simple rule.&lt;/p&gt;

&lt;p&gt;Keep state local unless multiple distant components truly depend on it.&lt;/p&gt;

&lt;p&gt;Local state first.&lt;br&gt;
Lift state only when needed.&lt;br&gt;
Use context only for authentication or truly global concerns.&lt;/p&gt;

&lt;p&gt;Overengineering state early is like installing traffic lights in your driveway. It solves a problem you do not have.&lt;/p&gt;

&lt;p&gt;Complexity should be earned, not assumed.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Ignoring Type Safety in API Responses
&lt;/h2&gt;

&lt;p&gt;When integrating REST APIs, I defined strict interfaces for every response.&lt;/p&gt;

&lt;p&gt;Instead of treating responses as any, I wrote explicit types.&lt;/p&gt;

&lt;p&gt;This prevented:&lt;/p&gt;

&lt;p&gt;Accessing properties that do not exist&lt;br&gt;
Silent runtime failures&lt;br&gt;
Accidental shape mismatches&lt;/p&gt;

&lt;p&gt;TypeScript caught issues before they reached production.&lt;/p&gt;

&lt;p&gt;Strong typing is not about writing more code.&lt;br&gt;
It is about reducing uncertainty.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Allowing Unnecessary Re Renders
&lt;/h2&gt;

&lt;p&gt;As data grew, performance issues started appearing.&lt;/p&gt;

&lt;p&gt;React re renders are cheap at first.&lt;br&gt;
They become expensive when multiplied.&lt;/p&gt;

&lt;p&gt;To prevent unnecessary work, I used:&lt;/p&gt;

&lt;p&gt;React memo for stable components&lt;br&gt;
useMemo for expensive derived data&lt;br&gt;
useCallback when passing functions to child components&lt;/p&gt;

&lt;p&gt;I also paid attention to dependency arrays carefully.&lt;/p&gt;

&lt;p&gt;Performance optimization is not premature optimization when you are dealing with dynamic dashboards.&lt;/p&gt;

&lt;p&gt;It is maintenance prevention.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Letting Components Grow Unbounded
&lt;/h2&gt;

&lt;p&gt;Large components are one of the fastest ways to lose clarity.&lt;/p&gt;

&lt;p&gt;If a component:&lt;/p&gt;

&lt;p&gt;Fetches data&lt;br&gt;
Manages complex state&lt;br&gt;
Renders layout&lt;br&gt;
Handles business logic&lt;/p&gt;

&lt;p&gt;It becomes difficult to reason about.&lt;/p&gt;

&lt;p&gt;I split responsibilities into:&lt;/p&gt;

&lt;p&gt;Container components&lt;br&gt;
Presentational components&lt;br&gt;
Reusable UI elements&lt;/p&gt;

&lt;p&gt;Smaller pieces are easier to test, debug, and extend.&lt;/p&gt;

&lt;p&gt;It also makes onboarding easier for other developers.&lt;/p&gt;

&lt;p&gt;What I Learned&lt;/p&gt;

&lt;p&gt;Scalability is less about tools and more about discipline.&lt;/p&gt;

&lt;p&gt;React and TypeScript provide excellent foundations.&lt;/p&gt;

&lt;p&gt;But structure, separation of concerns, and clear decision making are what keep a project maintainable.&lt;/p&gt;

&lt;p&gt;You do not feel the benefit immediately.&lt;/p&gt;

&lt;p&gt;You feel it three months later when adding a new feature does not break everything.&lt;/p&gt;

&lt;p&gt;That is when you realize architecture matters.&lt;/p&gt;

&lt;p&gt;Final Thought&lt;/p&gt;

&lt;p&gt;Building front end applications is not just about getting features done.&lt;/p&gt;

&lt;p&gt;It is about making sure future changes are predictable.&lt;/p&gt;

&lt;p&gt;If you are working with React and TypeScript, focus early on:&lt;/p&gt;

&lt;p&gt;Clear separation of concerns&lt;br&gt;
Strong type definitions&lt;br&gt;
Controlled state growth&lt;br&gt;
Intentional performance decisions&lt;/p&gt;

&lt;p&gt;Your future self will thank you.&lt;/p&gt;

&lt;p&gt;At the end, add something natural like:&lt;/p&gt;

&lt;p&gt;You can explore the full project and other work on my portfolio here: &lt;/p&gt;

&lt;p&gt;&lt;a href="//mehrabdev.com"&gt;https://mehrabdev.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>react</category>
      <category>typescript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
