<?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: Ndeye Fatou Diop</title>
    <description>The latest articles on DEV Community by Ndeye Fatou Diop (@_ndeyefatoudiop).</description>
    <link>https://dev.to/_ndeyefatoudiop</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%2F440984%2Fe06f206e-d5aa-428b-9034-e1f607c5a943.jpg</url>
      <title>DEV Community: Ndeye Fatou Diop</title>
      <link>https://dev.to/_ndeyefatoudiop</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/_ndeyefatoudiop"/>
    <language>en</language>
    <item>
      <title>Devs: Own your growth — or regret it later</title>
      <dc:creator>Ndeye Fatou Diop</dc:creator>
      <pubDate>Thu, 10 Jul 2025 10:00:00 +0000</pubDate>
      <link>https://dev.to/_ndeyefatoudiop/devs-own-your-growth-or-regret-it-later-ooj</link>
      <guid>https://dev.to/_ndeyefatoudiop/devs-own-your-growth-or-regret-it-later-ooj</guid>
      <description>&lt;p&gt;In 2019, one year after joining a dream company, I was frustrated.&lt;/p&gt;

&lt;p&gt;I realized I wanted to switch to another area of software engineering (frontend), but I didn’t know how 🤷‍♀️.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No one would give me a step-by-step plan to achieve it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;All my life, I was used to having either my parents, teachers, or family provide me with a simple roadmap to follow.&lt;/p&gt;

&lt;p&gt;I was expecting the same from my managers here.&lt;/p&gt;

&lt;p&gt;Fast forward to today: I’m a Senior Frontend Engineer, and I got here by &lt;strong&gt;owning my growth path&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In this post, I’ll explain why you always need to own your growth as a dev — and why not doing so is reckless.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ready? Let’s get started! 🚀&lt;/p&gt;




&lt;p&gt;&lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" class="crayons-btn crayons-btn--primary" rel="noopener noreferrer"&gt;📚 Download my FREE 101 React Tips And Tricks Book for a head start.&lt;/a&gt;
&lt;/p&gt;




&lt;h2&gt;
  
  
  What it means to own your growth as a dev
&lt;/h2&gt;

&lt;p&gt;Owning your growth as a dev, especially a junior one, means:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Being clear about where you want to be in 1, 3, and 5 years.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Sharing your goals with people who can help you.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Having a plan to reach your goals (and refining it with your manager).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Following up on the plan.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Re-adapting and adjusting when things change.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Why it’s essential to own your growth
&lt;/h2&gt;

&lt;p&gt;As a (junior) dev, it’s way too easy to be passive and wait for opportunities.&lt;/p&gt;

&lt;p&gt;Don’t get me wrong: that’s not always bad.&lt;/p&gt;

&lt;p&gt;You can get pretty far with a fantastic manager and a bit of luck on projects.&lt;/p&gt;

&lt;p&gt;But it’s &lt;strong&gt;dangerous to stay in the backseat of your career&lt;/strong&gt;. Here’s why:&lt;/p&gt;




&lt;h3&gt;
  
  
  Reason #1: “If you don't set goals, you will always work for someone who does.”
&lt;/h3&gt;

&lt;p&gt;That’s just the truth.&lt;/p&gt;

&lt;p&gt;If you don’t have a clear idea of where you want to go, you’ll end up working for someone else’s goals.&lt;/p&gt;

&lt;p&gt;That’s not necessarily bad if your goals align.&lt;/p&gt;

&lt;p&gt;But when they don’t, 5 years down the road, you might realize you’re unhappy, stuck in a role that doesn’t fulfill you 🥲.&lt;/p&gt;




&lt;h3&gt;
  
  
  Reason #2: Working toward your goals brings you more supporters
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Have you heard of the analogy about pushing a broken car?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It goes like this:&lt;/p&gt;

&lt;p&gt;It’s much easier to help someone who’s already pushing their broken car than someone who’s just standing next to it, waiting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because movement attracts help.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;People are far more likely to jump in and assist when they see you taking action, even if it’s messy or slow.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So if you’re stuck, start pushing.&lt;/p&gt;

&lt;p&gt;You’ll be amazed at who shows up to give you a hand.&lt;/p&gt;




&lt;h3&gt;
  
  
  Reason #3: Owning your growth gives you more credibility
&lt;/h3&gt;

&lt;p&gt;When you own your growth, set goals, and work toward them, it’s easy to imagine you doing the same for a team.&lt;/p&gt;

&lt;p&gt;Owning your growth shows strong ownership — a trait that accelerates your career.&lt;/p&gt;




&lt;h3&gt;
  
  
  Reason #4: Other people are also trying to figure it out
&lt;/h3&gt;

&lt;p&gt;As a junior dev, I used to look at folks with 3+ years of experience and think:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“Wow, they’ve figured it all out.”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Fast forward to today — after 5+ years — I’ve realized you never really figure it out 😅.&lt;/p&gt;

&lt;p&gt;The problems get harder.&lt;/p&gt;

&lt;p&gt;As a manager, I see this too: I can give some advice, but until someone comes to me with &lt;strong&gt;clear goals&lt;/strong&gt;, it can be pretty generic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But if you arrive with a clear goal and a rough plan, it’s much easier to provide you with tailored, helpful advice.&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Reason #5: Having clear goals helps you adjust when things change
&lt;/h3&gt;

&lt;p&gt;Tech changes all the time. Look at how AI is reshaping everything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Clear goals act like a north star.&lt;/strong&gt; They let you reassess: is this new tech going to help or hurt in reaching them?&lt;/p&gt;

&lt;p&gt;Without that, you’ll drift wherever the wind blows — and might wake up in a place you hate.&lt;/p&gt;




&lt;h2&gt;
  
  
  How to own your growth
&lt;/h2&gt;

&lt;p&gt;Alright, so how do you actually do it?&lt;/p&gt;

&lt;p&gt;Let me start with a personal example.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;My story:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In 2019, I wanted to transition into frontend development. So I:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Made this goal clear to my manager.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Talked to as many people as possible who’d made the switch.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Applied all their tips (learned JavaScript, contributed to the product, etc.).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Shared my progress regularly with my manager.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Repeated the cycle — contribute → share → repeat — until the right opportunity came up. Then I made the transition.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;strong&gt;What you can do:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you’re not currently owning your growth, here’s how to start:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Set goals (or anti-goals):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Where do you want to be in 1, 3, 5 years? Do you want to be an IC, a manager, or earn a specific comp?  &lt;/p&gt;

&lt;p&gt;Can’t come up with goals?  &lt;/p&gt;

&lt;p&gt;👉 Try &lt;strong&gt;anti-goals&lt;/strong&gt;: what does your nightmare life look like? (low pay, endless meetings, outdated skills). Then work backwards to avoid it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Come up with a plan:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Start with a simple 3-year plan, a clearer 2-year plan, and a more detailed 1-year plan.  &lt;/p&gt;

&lt;p&gt;The plan doesn’t have to be perfect or set in stone. It’s mainly a conversation starter.  &lt;/p&gt;

&lt;p&gt;Remember, &lt;em&gt;“Complexity is the enemy of execution.”&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Share and refine the plan:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Don’t just tell your manager, &lt;em&gt;“This is what I want.”&lt;/em&gt;  &lt;/p&gt;

&lt;p&gt;Say, &lt;em&gt;“This is what I want, and here’s how I plan to get there.”&lt;/em&gt;  &lt;/p&gt;

&lt;p&gt;Then gather feedback, adjust accordingly, and ensure it aligns with the business's needs as well.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Work toward the plan every day:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Show up consistently. Small steps daily beat occasional giant leaps.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Share your progress:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Don’t be shy. Sharing wins builds trust and shows commitment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Reassess and adjust:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Plans change. Don’t abandon ship at the first hurdle — some things take time.  &lt;/p&gt;

&lt;p&gt;As Warren Buffett said, &lt;em&gt;“You can't produce a baby in one month by getting nine women pregnant.”.&lt;/em&gt;  &lt;/p&gt;

&lt;p&gt;But also don’t be afraid to pivot if needed.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Keep setting goals:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
It’s easy to coast when things go well. But this is a never-ending process.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;You’re cheating yourself if you’re not owning your growth as a dev.&lt;/p&gt;

&lt;p&gt;Owning your growth means having goals (or anti-goals) and working toward them.&lt;/p&gt;

&lt;p&gt;If you don’t, you’re 99% more likely to wake up one day in the wrong place, full of regrets.&lt;/p&gt;

&lt;p&gt;It’s not that hard: set goals, build a plan, share it, work on it, show your progress, adjust — repeat.&lt;/p&gt;

&lt;p&gt;That’s it.&lt;/p&gt;

&lt;p&gt;You’ve got this.&lt;/p&gt;

&lt;p&gt;Become the amazing developer you’re meant to be 💪.&lt;/p&gt;




&lt;p&gt;If you're learning React, download my &lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" rel="noopener noreferrer"&gt;101 React Tips &amp;amp; Tricks book&lt;/a&gt; for &lt;strong&gt;FREE&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you like articles like this, join my &lt;strong&gt;FREE&lt;/strong&gt; newsletter, &lt;strong&gt;&lt;a href="https://frontendjoy.com/" rel="noopener noreferrer"&gt;FrontendJoy&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you want daily tips, find me on &lt;a href="https://twitter.com/_ndeyefatoudiop" rel="noopener noreferrer"&gt;X/Twitter&lt;/a&gt; or &lt;a href="https://bsky.app/profile/ndeyefatoudiop.bsky.social" rel="noopener noreferrer"&gt;Bluesky&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>career</category>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>✨ 17 React Hooks That Power 90% of Modern Components</title>
      <dc:creator>Ndeye Fatou Diop</dc:creator>
      <pubDate>Tue, 20 May 2025 17:32:36 +0000</pubDate>
      <link>https://dev.to/_ndeyefatoudiop/17-react-hooks-that-power-90-of-modern-components-439b</link>
      <guid>https://dev.to/_ndeyefatoudiop/17-react-hooks-that-power-90-of-modern-components-439b</guid>
      <description>&lt;p&gt;&lt;strong&gt;New to React?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If yes, you’ve probably wondered what hooks you really need—or worse, you’ve been copying the same logic over and over without realizing it.&lt;/p&gt;

&lt;p&gt;This post covers all the React hooks you’ll likely need in your project.&lt;/p&gt;

&lt;p&gt;Let’s dive in 🎉.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" class="crayons-btn crayons-btn--primary" rel="noopener noreferrer"&gt;📚 Download my FREE 101 React Tips And Tricks Book for a head start.&lt;/a&gt;
&lt;/p&gt;




&lt;h2&gt;
  
  
  1. useState
&lt;/h2&gt;

&lt;p&gt;This hook is unavoidable.&lt;/p&gt;

&lt;p&gt;Whenever you need dynamic state that persists across re-renders, this is the one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  2. useReducer
&lt;/h2&gt;

&lt;p&gt;Once your state becomes complex (e.g. multiple correlated fields), &lt;code&gt;useReducer&lt;/code&gt; becomes your friend.&lt;/p&gt;

&lt;p&gt;It also pairs really well with &lt;code&gt;useContext&lt;/code&gt;, letting you update state with simple &lt;code&gt;dispatch&lt;/code&gt; calls.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;reducer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;action&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="k"&gt;switch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;addTodo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;removeTodo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="c1"&gt;// TODO: Implement logic&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;toggleTodo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="c1"&gt;// TODO: Implement logic&lt;/span&gt;
    &lt;span class="na"&gt;default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useReducer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;reducer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  3. useContext
&lt;/h2&gt;

&lt;p&gt;When prop drilling gets out of hand, this hook saves the day.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Prop drilling&lt;/strong&gt; = passing props through multiple layers just to reach a deeply nested component.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Use &lt;code&gt;useContext&lt;/code&gt; to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;manage global state in small apps&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;share data like the authenticated user&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;avoid passing props manually everywhere&lt;br&gt;
&lt;/p&gt;&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;const&lt;/span&gt; &lt;span class="nx"&gt;UserContext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createContext&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&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="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;UserContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Provider&lt;/span&gt; &lt;span class="na"&gt;value&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="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* ... */&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;UserContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Provider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Profile&lt;/span&gt;&lt;span class="p"&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;useContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;UserContext&lt;/span&gt;&lt;span class="p"&gt;);&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="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello &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="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;h2&gt;
  
  
  4. useEffect
&lt;/h2&gt;

&lt;p&gt;You should avoid it 99% of the time.&lt;br&gt;&lt;br&gt;
(See: &lt;a href="https://react.dev/learn/you-might-not-need-an-effect" rel="noopener noreferrer"&gt;You Might Not Need an Effect&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;But in real life, you’ll still need it—especially for things like syncing with external systems.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;useSetDocumentTitle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;title&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="nf"&gt;useEffect&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="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  5. useRef
&lt;/h2&gt;

&lt;p&gt;You should never directly manipulate the DOM in React.&lt;/p&gt;

&lt;p&gt;But when you must (e.g. for canvas, chart libraries…), &lt;code&gt;useRef&lt;/code&gt; is the safe way.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ExampleChart&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="p"&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;canvasRef&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useRef&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="nf"&gt;useEffect&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;ctx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;canvasRef&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&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;chart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Chart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bar&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;row&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;row&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;year&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="na"&gt;datasets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Likes&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}],&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;chart&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;destroy&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&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="nt"&gt;canvas&lt;/span&gt; &lt;span class="na"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;canvasRef&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;h2&gt;
  
  
  6. useMemo / useCallback
&lt;/h2&gt;

&lt;p&gt;These may become optional thanks to the new React Compiler—but for now, they’re still useful.&lt;/p&gt;

&lt;p&gt;Use &lt;code&gt;useMemo&lt;/code&gt; when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;an expensive computation should not re-run on every render&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;you're memoizing a non-primitive dependency&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;you're passing values to &lt;code&gt;memo&lt;/code&gt;-wrapped components&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use &lt;code&gt;useCallback&lt;/code&gt; to memoize functions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useMemo&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;computeTotal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;items&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;handleClick&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useCallback&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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;clicked&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  7. useLayoutEffect
&lt;/h2&gt;

&lt;p&gt;This one is rare but useful.&lt;/p&gt;

&lt;p&gt;It runs &lt;strong&gt;before paint&lt;/strong&gt;, which helps prevent layout shifts or flickering UI.&lt;/p&gt;

&lt;p&gt;See real examples here: &lt;a href="https://www.developerway.com/posts/no-more-flickering-ui" rel="noopener noreferrer"&gt;No more flickering UI&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you’re not comfortable with React components lifecycle, check my post ✨ &lt;a href="https://www.frontendjoy.com/p/react-lifecycle-in-3-minutes" rel="noopener noreferrer"&gt;&lt;strong&gt;React Lifecycle in 3 Minutes&lt;/strong&gt;&lt;/a&gt; 😉&lt;strong&gt;.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="nf"&gt;useLayoutEffect&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;height&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;offsetHeight&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;setHeight&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  8. useSWR / useQuery
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://swr.vercel.app/" rel="noopener noreferrer"&gt;SWR&lt;/a&gt; and &lt;a href="https://tanstack.com/query/latest" rel="noopener noreferrer"&gt;TanStack Query&lt;/a&gt; are becoming the standard for fetching data in React.&lt;/p&gt;

&lt;p&gt;SWR is simpler and great for most use cases while TanStack Query is more complex and powerful.&lt;/p&gt;

&lt;h3&gt;
  
  
  SWR
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fetcher&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;isLoading&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useSWR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/api/user&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fetcher&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  TanStack Query
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getUser&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="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/api/user&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;isLoading&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useQuery&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;queryKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;queryFn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;getUser&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  9. useSelector, useDispatch, or other state hooks
&lt;/h2&gt;

&lt;p&gt;Sometimes React’s built-in state tools aren’t enough.&lt;/p&gt;

&lt;p&gt;You’ll then see these hooks depending on the state library:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;useSelector&lt;/code&gt;, &lt;code&gt;useDispatch&lt;/code&gt; from &lt;a href="https://react-redux.js.org/" rel="noopener noreferrer"&gt;react-redux&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;useAtom&lt;/code&gt; from &lt;a href="https://jotai.org/docs" rel="noopener noreferrer"&gt;Jotai&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  10. useNavigate
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://reactrouter.com/" rel="noopener noreferrer"&gt;React Router&lt;/a&gt; is very popular.&lt;/p&gt;

&lt;p&gt;So is its navigation hook:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;navigate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useNavigate&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nf"&gt;navigate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/profile&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Now, let’s talk about hooks I reach for in nearly every app—even though they’re not built into React.&lt;/p&gt;




&lt;h2&gt;
  
  
  11. useBoolean
&lt;/h2&gt;

&lt;p&gt;One of my all-time favorites.&lt;/p&gt;

&lt;p&gt;It makes managing boolean state super clean.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;isOpen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setFalse&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;toggle&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useBoolean&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;toggle&lt;/span&gt;&lt;span class="si"&gt;}&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;isOpen&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Close form&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Open form&lt;/span&gt;&lt;span class="dl"&gt;"&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;button&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="nc"&gt;Dialog&lt;/span&gt; &lt;span class="na"&gt;isOpen&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;isOpen&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;onClose&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;setFalse&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* Form content */&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Dialog&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;/&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  12. useCopyToClipboard
&lt;/h2&gt;

&lt;p&gt;Perfect for "copy" buttons.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;copiedText&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useCopyToClipboard&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;handleCopy&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="nf"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello World&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;errorToast&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Failed to copy!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleCopy&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Copy&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&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;copiedText&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;span&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Copied!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;span&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;/&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  13. usePrevious
&lt;/h2&gt;

&lt;p&gt;Use this to compare current vs. previous values.&lt;/p&gt;

&lt;p&gt;Great for triggering actions based on changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;prevCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;usePrevious&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&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;didIncrease&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;prevCount&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;prevCount&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;useEffect&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;didIncrease&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Count increased!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;didIncrease&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  14. useDebounce
&lt;/h2&gt;

&lt;p&gt;Debounce your requests to avoid unnecessary API calls.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setQuery&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;debouncedQuery&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useDebounce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useSWR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`/api/search?q=&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;debouncedQuery&lt;/span&gt;&lt;span class="p"&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;fetcher&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&amp;gt;&lt;/span&gt; 
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;input&lt;/span&gt;
      &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="na"&gt;onChange&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setQuery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="na"&gt;placeholder&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Search..."&lt;/span&gt;
    &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* TODO: Show data */&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;/&amp;gt;&lt;/span&gt;

&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  15. useMediaQuery
&lt;/h2&gt;

&lt;p&gt;Want to render different things based on screen size? This hook is for you.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;isMobile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useMediaQuery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;(max-width: 768px)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&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="nt"&gt;div&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;isMobile&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Mobile View&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Desktop View&lt;/span&gt;&lt;span class="dl"&gt;"&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;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  16. useResizeObserver
&lt;/h2&gt;

&lt;p&gt;Useful for responsive layouts or libraries like &lt;a href="https://github.com/bvaughn/react-window" rel="noopener noreferrer"&gt;react-window&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useRef&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useResizeObserver&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="k"&gt;return &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;ref&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    Width: &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;, Height: &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;height&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;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;h2&gt;
  
  
  17. useLocalStorage
&lt;/h2&gt;

&lt;p&gt;Store and sync data with &lt;code&gt;localStorage&lt;/code&gt; easily.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setTheme&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useLocalStorage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;theme&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;return &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;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&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="nf"&gt;setTheme&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dark&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    Switch to &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dark&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;"&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;button&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;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;That’s it!&lt;/p&gt;

&lt;p&gt;These 17 hooks are more than enough to cover most use cases in any React app.&lt;/p&gt;

&lt;p&gt;Pick your favorites and use them in your next project 😉.&lt;/p&gt;




&lt;p&gt;If you're learning React, download my &lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" rel="noopener noreferrer"&gt;101 React Tips &amp;amp; Tricks book&lt;/a&gt; for &lt;strong&gt;FREE&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you like articles like this, join my &lt;strong&gt;FREE&lt;/strong&gt; newsletter, &lt;strong&gt;&lt;a href="https://frontendjoy.com/" rel="noopener noreferrer"&gt;FrontendJoy&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you want daily tips, find me on &lt;a href="https://twitter.com/_ndeyefatoudiop" rel="noopener noreferrer"&gt;X/Twitter&lt;/a&gt; or &lt;a href="https://bsky.app/profile/ndeyefatoudiop.bsky.social" rel="noopener noreferrer"&gt;Bluesky&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>✨ 7 Things I Do Regularly as a Senior Frontend Developer</title>
      <dc:creator>Ndeye Fatou Diop</dc:creator>
      <pubDate>Wed, 07 May 2025 14:00:00 +0000</pubDate>
      <link>https://dev.to/_ndeyefatoudiop/7-habits-i-recommend-to-succeed-as-a-frontend-developer-57e</link>
      <guid>https://dev.to/_ndeyefatoudiop/7-habits-i-recommend-to-succeed-as-a-frontend-developer-57e</guid>
      <description>&lt;p&gt;I’ve been a frontend developer at Palantir for the past 5+ years.&lt;/p&gt;

&lt;p&gt;In this post, I’ll share habits that helped me go from overwhelmed junior dev to confident senior dev.&lt;/p&gt;

&lt;p&gt;Ready?&lt;/p&gt;

&lt;p&gt;Let’s get started! 🎉&lt;/p&gt;




&lt;p&gt;&lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" class="crayons-btn crayons-btn--primary" rel="noopener noreferrer"&gt;📚 Download my FREE 101 React Tips And Tricks Book for a head start.&lt;/a&gt;
&lt;/p&gt;




&lt;h2&gt;
  
  
  Habit #1: Educate yourself outside of work
&lt;/h2&gt;

&lt;p&gt;If you’re not learning outside of work, you’re falling behind.&lt;/p&gt;

&lt;p&gt;Even if you have the best employer in the world, your education is your responsibility.&lt;/p&gt;

&lt;p&gt;So, at least once every 2–4 weeks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Pick up books like &lt;a href="https://pragprog.com/titles/tpp20/the-pragmatic-programmer-20th-anniversary-edition/" rel="noopener noreferrer"&gt;&lt;em&gt;The Pragmatic Programmer&lt;/em&gt;&lt;/a&gt;, &lt;a href="https://effectivetypescript.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Effective TypeScript&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;, or &lt;a href="https://www.advanced-react.com/" rel="noopener noreferrer"&gt;&lt;em&gt;Advanced React&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Read blog posts from experts like &lt;em&gt;Matt Pocock&lt;/em&gt; (&lt;a href="https://www.totaltypescript.com/articles" rel="noopener noreferrer"&gt;Total TypeScript&lt;/a&gt;), &lt;em&gt;Josh Comeau&lt;/em&gt; (&lt;a href="https://joshwcomeau.com" rel="noopener noreferrer"&gt;joshwcomeau.com&lt;/a&gt;), &lt;em&gt;Kent C. Dodds&lt;/em&gt; (&lt;a href="https://www.epicreact.dev/articles" rel="noopener noreferrer"&gt;Epic React&lt;/a&gt;), etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Watch courses to review your basics (&lt;a href="https://www.udemy.com/" rel="noopener noreferrer"&gt;Udemy&lt;/a&gt;, &lt;a href="https://frontendmasters.com/" rel="noopener noreferrer"&gt;FrontendMasters&lt;/a&gt;, etc.)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The more you learn, the more efficient you’ll be at work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frrxf0p0xqw1e9ksai0ui.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frrxf0p0xqw1e9ksai0ui.png" alt="AI-generated image of a dev reading Effective TypeScript book"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Habit #2: Work on different projects and skills every month
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The worst thing that can happen to a frontend dev?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 Getting stale.&lt;/p&gt;

&lt;p&gt;Especially in the age of AI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Working on the same type of project over and over slows your growth.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You have fewer tools to solve problems&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You get less flexible and adaptable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You become easier to replace&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Try new things every month. If you can’t at work, explore with side projects.&lt;/p&gt;




&lt;h2&gt;
  
  
  Habit #3: Get enough rest
&lt;/h2&gt;

&lt;p&gt;The less sleep I get, the more bugs I ship 😅.&lt;/p&gt;

&lt;p&gt;Your brain needs rest. And what that looks like depends on you.&lt;/p&gt;

&lt;p&gt;But one thing’s for sure: &lt;strong&gt;you can’t cheat sleep&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Getting enough rest keeps your mind sharp and your code cleaner.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu2gurth0hi5nkmp8as5u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu2gurth0hi5nkmp8as5u.png" alt="Rest and recharge!"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Habit #4: Stay in touch with what’s happening in the frontend world
&lt;/h2&gt;

&lt;p&gt;I still see devs who ignore AI (and other new tech trends).&lt;/p&gt;

&lt;p&gt;This breaks my heart 🥲.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Most devs who ignore change will eventually get replaced by it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You don’t need to jump on every trend. You don’t need to use the latest framework.&lt;/p&gt;

&lt;p&gt;But you do need to stay aware. Pay attention. &lt;strong&gt;Adapt when it makes sense.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Otherwise? You’ll slowly become obsolete.&lt;/p&gt;




&lt;h2&gt;
  
  
  Habit #5: Review code regularly
&lt;/h2&gt;

&lt;p&gt;Code reviews are underrated 🙂.&lt;/p&gt;

&lt;p&gt;Not just for the code author, but for &lt;em&gt;you&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;I’ve learned countless patterns and tricks just by reviewing code.&lt;/p&gt;

&lt;p&gt;It’s a simple way to grow while helping your teammates.&lt;/p&gt;

&lt;p&gt;No access to reviews at work? Browse open-source projects on GitHub and read PRs.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 Check out these &lt;a href="https://maxrozen.com/examples-of-large-production-grade-open-source-react-apps?utm_source=www.frontendjoy.com&amp;amp;utm_medium=referral&amp;amp;utm_campaign=how-to-level-up-your-frontend-skills" rel="noopener noreferrer"&gt;&lt;strong&gt;examples of large, production-grade open-source React apps&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F74ob50aycdhuq7qkkffs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F74ob50aycdhuq7qkkffs.png" alt="AI-generated image of two devs (one reviewing the code for the other one)"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Habit #6: Teach back what you learn
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;“If you can't explain it simply, you don't understand it well enough.” — Albert Einstein&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Teaching forces you to understand things deeply.&lt;/p&gt;

&lt;p&gt;I’ve often thought I knew something—until I tried to explain it.&lt;/p&gt;

&lt;p&gt;That’s when I realize I don’t actually get it yet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Teaching is a shortcut to mastery.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Run internal sessions at work.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Write on a blog.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Record short videos.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Anything works 😉.&lt;/p&gt;




&lt;h2&gt;
  
  
  Habit #7: Avoid tutorials and copy/pasting
&lt;/h2&gt;

&lt;p&gt;Tutorials are fine—in small doses.&lt;/p&gt;

&lt;p&gt;But they quickly become a way to &lt;em&gt;avoid&lt;/em&gt; learning, not to encourage it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instead of binge-watching, try to build something. Use tutorials only when you’re stuck.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Same with copy/pasting code.&lt;/p&gt;

&lt;p&gt;If you don’t understand what you’re pasting, you won’t remember it. And you’ll keep repeating the cycle.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 Quick tip: if it’s a piece of code you use often but don’t want to memorize, save it as a snippet (like in &lt;a href="https://code.visualstudio.com/docs/editing/userdefinedsnippets" rel="noopener noreferrer"&gt;VS Code snippets&lt;/a&gt;).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdgyihe6tc9eaxju9vhj0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdgyihe6tc9eaxju9vhj0.png" alt="AI-generated image of a dev struggling because of tutorials"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Becoming a great frontend dev takes time.&lt;/p&gt;

&lt;p&gt;But these 7 small habits can make a &lt;em&gt;huge&lt;/em&gt; difference over the long run.&lt;/p&gt;

&lt;p&gt;What’s next?&lt;/p&gt;

&lt;p&gt;Pick just one—and try it this week 🙂.&lt;/p&gt;




&lt;p&gt;If you're learning React, download my &lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" rel="noopener noreferrer"&gt;101 React Tips &amp;amp; Tricks book&lt;/a&gt; for &lt;strong&gt;FREE&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you like articles like this, join my &lt;strong&gt;FREE&lt;/strong&gt; newsletter, &lt;strong&gt;&lt;a href="https://frontendjoy.com/" rel="noopener noreferrer"&gt;FrontendJoy&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you want daily tips, find me on &lt;a href="https://twitter.com/_ndeyefatoudiop" rel="noopener noreferrer"&gt;X/Twitter&lt;/a&gt; or &lt;a href="https://bsky.app/profile/ndeyefatoudiop.bsky.social" rel="noopener noreferrer"&gt;Bluesky&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>frontend</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>✨ Don’t do this (unless you want sh*t frontend code)</title>
      <dc:creator>Ndeye Fatou Diop</dc:creator>
      <pubDate>Mon, 05 May 2025 14:30:00 +0000</pubDate>
      <link>https://dev.to/_ndeyefatoudiop/dont-do-this-unless-you-want-sht-frontend-code-4203</link>
      <guid>https://dev.to/_ndeyefatoudiop/dont-do-this-unless-you-want-sht-frontend-code-4203</guid>
      <description>&lt;p&gt;&lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" class="crayons-btn crayons-btn--primary" rel="noopener noreferrer"&gt;📚 Download my FREE 101 React Tips And Tricks Book for a head start.&lt;/a&gt;
&lt;/p&gt;




&lt;p&gt;It’s easy to end up with messy frontend code.&lt;/p&gt;

&lt;p&gt;In this post, I’ll show you &lt;strong&gt;17 things to avoid&lt;/strong&gt; if you want to keep your frontend code clean and maintainable.&lt;/p&gt;

&lt;p&gt;Let’s dive in 👇&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Mistake #1: Using too many global variables&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Global variables are accessible from anywhere in your app, which makes them risky.&lt;/p&gt;

&lt;p&gt;If you change one in a random place, you can unintentionally break something elsewhere, and that’s a nightmare to debug.&lt;/p&gt;

&lt;p&gt;They also make testing harder, since the function's behavior might change depending on the global state.&lt;/p&gt;

&lt;p&gt;Use function arguments or scoped variables instead.&lt;/p&gt;

&lt;p&gt;❌ &lt;strong&gt;Bad:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;userRole&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;guest&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;canEditPost&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;userRole&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;userRole&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Changes app behavior unexpectedly&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Better:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;canEditPost&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userRole&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;userRole&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&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;role&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;canEditPost&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;role&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Mistake #2: Poor variable and function names&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Using vague names like &lt;code&gt;x&lt;/code&gt;, &lt;code&gt;data&lt;/code&gt;, or &lt;code&gt;handleStuff&lt;/code&gt; slows everyone down.&lt;/p&gt;

&lt;p&gt;Readers (including future you) will need to guess what each thing does — or worse, scroll around to find out.&lt;/p&gt;

&lt;p&gt;A good rule of thumb: the bigger the scope, the more descriptive the name should be.&lt;/p&gt;

&lt;p&gt;Short loops? &lt;code&gt;i&lt;/code&gt; is fine.&lt;/p&gt;

&lt;p&gt;Longer scope? Use names that tell the whole story.&lt;/p&gt;

&lt;p&gt;❌ &lt;strong&gt;Bad:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&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;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Better:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculateDiscount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;originalPrice&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;discountAmount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;originalPrice&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;discountAmount&lt;/span&gt;&lt;span class="p"&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;finalPrice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculateDiscount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Mistake #3: “God” functions&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;These functions try to do everything — validate input, update UI, fetch data, handle errors — all in one place.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;result&lt;/strong&gt;? Long, messy functions that are painful to test and debug.&lt;/p&gt;

&lt;p&gt;Instead, &lt;strong&gt;split logic into smaller, focused functions&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This &lt;strong&gt;improves readability&lt;/strong&gt;, makes it easier to write &lt;strong&gt;unit tests&lt;/strong&gt;, and helps you reuse logic in other places too.&lt;/p&gt;

&lt;p&gt;❌ &lt;strong&gt;Bad:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handleFormSubmit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;preventDefault&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;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&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;value&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;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Invalid form&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;setLoading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/api/submit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&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;email&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nf"&gt;navigate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/dashboard&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&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="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Something went wrong&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;finally&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setLoading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Better:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handleFormSubmit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;preventDefault&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;formData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getFormData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;isValidForm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;formData&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Invalid form&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;submitForm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;formData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getFormData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&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="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&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;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isValidForm&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;email&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;submitForm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;setLoading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&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;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/api/submit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&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;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nf"&gt;setUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nf"&gt;navigate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/dashboard&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Something went wrong&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;setLoading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Mistake #4: Functions with many same-type params&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;When a function has several parameters of the same type — like booleans or strings — it’s easy to mix them up.&lt;/p&gt;

&lt;p&gt;Instead, &lt;strong&gt;pass an object with named keys&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That way, it’s clear what each value is for — and you don’t need to jump to the function definition to understand what’s going on.&lt;/p&gt;

&lt;p&gt;❌ &lt;strong&gt;Bad:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;createUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Better:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;createUser&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;isAdmin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;isVerified&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;isActive&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Mistake #5: Not cleaning up resources&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Whenever you add an event listener, create intervals, set timeouts, or use &lt;code&gt;useEffect&lt;/code&gt; in React, clean them up once they’re no longer needed.&lt;/p&gt;

&lt;p&gt;If you don’t, you could end up with &lt;strong&gt;memory leaks&lt;/strong&gt;, &lt;strong&gt;stacked event listeners&lt;/strong&gt;, or &lt;strong&gt;ghost network calls&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For frontend apps that run for a long time (such as dashboards or admin panels), these bugs can significantly impact performance — or even crash your app entirely.&lt;/p&gt;

&lt;p&gt;❌ &lt;strong&gt;Bad (React):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;useEffect&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="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;resize&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;handleResize&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Better:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;useEffect&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="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;resize&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;handleResize&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;removeEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;resize&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;handleResize&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Mistake #6: Unit-less variables&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If a value has a unit — like milliseconds, pixels, or megabytes — &lt;strong&gt;include that unit in the variable name&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Otherwise, other devs (or future you) will have to guess what the number means.&lt;/p&gt;

&lt;p&gt;❌ &lt;strong&gt;Bad:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;timeout&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Better:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;timeoutMs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Mistake #7: Nesting conditionals &amp;gt;3 levels deep&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;When your logic is nested more than 2 or 3 levels, it becomes hard to read and reason about, especially if you have lots of &lt;code&gt;if/else&lt;/code&gt; blocks.&lt;/p&gt;

&lt;p&gt;Instead, try to &lt;strong&gt;“flatten” your code&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Return early&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Invert the conditions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Split logic into smaller functions&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That makes each block easier to read and debug.&lt;/p&gt;

&lt;p&gt;❌ &lt;strong&gt;Bad:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&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;isAdmin&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&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;hasAccess&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// do stuff&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Better:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&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;isAdmin&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&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;hasAccess&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// do stuff&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Mistake #8: Hardcoding URLs or config in the code&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Hardcoding things like URLs, API keys, or environment-specific config is a trap.&lt;/p&gt;

&lt;p&gt;The moment that value changes, you’ll have to hunt it down across the codebase.&lt;/p&gt;

&lt;p&gt;Instead, &lt;strong&gt;store config values in constants or environment variables, then import them where needed&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You’ll avoid bugs, desyncs, and hours of wasted time.&lt;/p&gt;

&lt;p&gt;❌ &lt;strong&gt;Bad:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://api.example.com/posts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Better:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;API_BASE_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;API_BASE_URL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&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;API_BASE_URL&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/posts`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Mistake #9: Keeping dead code “just in case”&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;We’ve all done it — comment out some code and leave it there “just in case.”&lt;/p&gt;

&lt;p&gt;But here’s the truth: &lt;strong&gt;99% of the time, no one will ever use it&lt;/strong&gt; 😅. And no one wants to scroll past it.&lt;/p&gt;

&lt;p&gt;Use &lt;a href="https://github.com/" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; or &lt;a href="https://about.gitlab.com/" rel="noopener noreferrer"&gt;GitLab&lt;/a&gt; and delete that code.&lt;/p&gt;

&lt;p&gt;❌ &lt;strong&gt;Bad:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// old validation logic (maybe needed later)&lt;/span&gt;
&lt;span class="c1"&gt;// function validateInput(input) { ... }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Better:&lt;/strong&gt; Just delete it.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Mistake #10: Giant “utils” files&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The classic &lt;code&gt;utils.js&lt;/code&gt; file always starts innocent, then slowly turns into a kitchen sink of random functions.&lt;/p&gt;

&lt;p&gt;Before you know it, it’s hundreds of lines long and impossible to navigate.&lt;/p&gt;

&lt;p&gt;Instead, &lt;strong&gt;colocate utility functions near the code that uses them&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Or, &lt;strong&gt;split&lt;/strong&gt; them into &lt;strong&gt;focused files&lt;/strong&gt; like &lt;code&gt;arrayUtils.js&lt;/code&gt;, &lt;code&gt;dateUtils.js&lt;/code&gt;, etc.&lt;/p&gt;

&lt;p&gt;❌ &lt;strong&gt;Bad:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// utils.js&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;doStuff&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Better:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// listUtils.js (next to List component)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getVisibleItems&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;visible&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;category&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Mistake #11: Swallowing errors&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If your code might throw an error, don’t just ignore it.&lt;/p&gt;

&lt;p&gt;Swallowed errors are a nightmare to debug, especially in production.&lt;/p&gt;

&lt;p&gt;Even a simple &lt;code&gt;console.error&lt;/code&gt; can save hours of guessing.&lt;/p&gt;

&lt;p&gt;And if users are affected, &lt;strong&gt;show an indication in the UI so they know something went wrong&lt;/strong&gt; (instead of a blank screen).&lt;/p&gt;

&lt;p&gt;❌ &lt;strong&gt;Bad:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;riskyFunction&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// nothing&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Better&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;riskyFunction&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Error in riskyFunction:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;showToast&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;TODO: Useful error message + actions&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Mistake #12: One giant file&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;When everything is contained in a single file — components, logic, styling, and state — the file grows rapidly.&lt;/p&gt;

&lt;p&gt;You end up with 800+ lines of scroll hell 🔥.&lt;/p&gt;

&lt;p&gt;Instead:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Split things up.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Group related code into folders and give each file a clear role.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It &lt;strong&gt;lowers the cognitive load&lt;/strong&gt; and makes onboarding new devs much easier.&lt;/p&gt;

&lt;p&gt;❌ &lt;strong&gt;Bad:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// App.js — 1000+ lines of code&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Better:&lt;/strong&gt; Split it up into folders:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;/components
/context
/pages
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Mistake #13: No linter&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Linters like ESLint catch issues &lt;strong&gt;before&lt;/strong&gt; they hit production, from simple bugs to missing React dependencies in &lt;code&gt;useEffect&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;They also help standardize code style across a team.&lt;/p&gt;

&lt;p&gt;Please ensure you read and act on the warnings: don’t just slap &lt;code&gt;// eslint-disable&lt;/code&gt; everywhere 😉.&lt;/p&gt;

&lt;p&gt;❌ &lt;strong&gt;Bad:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;useEffect&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="nf"&gt;fetchData&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt; &lt;span class="c1"&gt;// missing fetchData in deps&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Better:&lt;/strong&gt; Use ESLint + React hooks plugin. It will warn you:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;React Hook useEffect has a missing dependency: 'fetchData'.&lt;/code&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Mistake #14: Messy folder structure&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Your project folder shouldn’t feel like a junk drawer.&lt;/p&gt;

&lt;p&gt;When files are scattered randomly, it’s challenging to find anything, and this difficulty is compounded when scaling the app.&lt;/p&gt;

&lt;p&gt;Instead, &lt;strong&gt;use a structure based on features or domains.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Group related files together so new devs can quickly understand what’s what.&lt;/p&gt;

&lt;p&gt;❌ &lt;strong&gt;Bad:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/src
  App.js
  helpers.js
  styles.css
  randomStuff.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Better:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;/src
  /components
  /services
  App.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Mistake #15: Commenting obvious code&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;You don’t need to explain what &lt;code&gt;let count = 0&lt;/code&gt; means.&lt;/p&gt;

&lt;p&gt;Trust your reader 😉.&lt;/p&gt;

&lt;p&gt;If something’s confusing, &lt;strong&gt;try simplifying the logic or using clearer names&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Comments should explain &lt;em&gt;why&lt;/em&gt; something is done, not &lt;em&gt;what&lt;/em&gt; a line of code does.&lt;/p&gt;

&lt;p&gt;❌ &lt;strong&gt;Bad:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Set count to 0&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Better:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;itemCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Mistake #16: No comments for weird logic&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Sometimes you need to add a workaround or support a legacy case.&lt;/p&gt;

&lt;p&gt;That’s fine — but &lt;strong&gt;explain *why&lt;/strong&gt;*.&lt;/p&gt;

&lt;p&gt;Without a comment, your teammates (or future you) will waste time trying to understand what &lt;code&gt;magicFix42(data)&lt;/code&gt; means.&lt;/p&gt;

&lt;p&gt;Leave a short note. You’ll thank yourself later.&lt;/p&gt;

&lt;p&gt;❌ &lt;strong&gt;Bad:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;magicFix42&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Better:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Applies patch for backend bug #321. Read ticket for more context &lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;magicFix42&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Mistake #17: Rewriting what already exists&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Don’t reinvent the wheel.&lt;/p&gt;

&lt;p&gt;There are tons of small, reliable libraries built by people smarter than us.&lt;/p&gt;

&lt;p&gt;If you can solve the problem with a trusted package, use it.&lt;/p&gt;

&lt;p&gt;Just keep your dependencies in check so your bundle size doesn’t balloon (check my post ✨ &lt;a href="https://www.frontendjoy.com/p/how-i-reduced-my-react-bundle-size-by-30-with-real-examples" rel="noopener noreferrer"&gt;How I Reduced My React Bundle Size by 30% (With Real Examples)&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;🟠 &lt;strong&gt;Ok:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;debounce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;timer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;clearTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timer&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;timer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Easier:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;debounce&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lodash-es&lt;/span&gt;&lt;span class="dl"&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;debouncedFn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;debounce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;myFn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Summary&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Frontend code can get messy fast.&lt;/p&gt;

&lt;p&gt;Avoid these 17 mistakes, and your code will be easier to read, debug, and maintain.&lt;/p&gt;

&lt;p&gt;Your future self—and your teammates—will thank you.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;iframe&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://embeds.beehiiv.com/4b52f101-5150-4e42-abc6-28785fdd68cd"&lt;/span&gt; &lt;span class="na"&gt;data-test-id=&lt;/span&gt;&lt;span class="s"&gt;"beehiiv-embed"&lt;/span&gt; &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;"100%"&lt;/span&gt; &lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;"320"&lt;/span&gt; &lt;span class="na"&gt;frameborder=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"border-radius: 4px; border: 2px solid #e5e7eb; margin: 0; background-color: transparent;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;That's a wrap 🎉.&lt;/p&gt;

&lt;p&gt;Leave a comment 📩 to add one more tip.&lt;/p&gt;

&lt;p&gt;And don't forget to drop a "💖🦄🔥".&lt;/p&gt;

&lt;p&gt;If you're learning React, download my &lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" rel="noopener noreferrer"&gt;101 React Tips &amp;amp; Tricks book&lt;/a&gt; for &lt;strong&gt;FREE&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you like articles like this, join my &lt;strong&gt;FREE&lt;/strong&gt; newsletter, &lt;strong&gt;&lt;a href="https://frontendjoy.com/" rel="noopener noreferrer"&gt;FrontendJoy&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you want daily tips, find me on &lt;a href="https://twitter.com/_ndeyefatoudiop" rel="noopener noreferrer"&gt;X/Twitter&lt;/a&gt; or &lt;a href="https://bsky.app/profile/ndeyefatoudiop.bsky.social" rel="noopener noreferrer"&gt;Bluesky&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>frontend</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Typescript to Know for React</title>
      <dc:creator>Ndeye Fatou Diop</dc:creator>
      <pubDate>Wed, 16 Apr 2025 11:00:00 +0000</pubDate>
      <link>https://dev.to/_ndeyefatoudiop/typescript-to-know-for-react-2p02</link>
      <guid>https://dev.to/_ndeyefatoudiop/typescript-to-know-for-react-2p02</guid>
      <description>&lt;p&gt;&lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" class="crayons-btn crayons-btn--primary" rel="noopener noreferrer"&gt;📚 Download my FREE 101 React Tips And Tricks Book for a head start.&lt;/a&gt;
&lt;/p&gt;




&lt;p&gt;Two weeks ago, I stumbled upon this post on Reddit: &lt;a href="https://www.reddit.com/r/react/comments/1jnadak/should_i_learn_react_with_typescript_or_javascript/" rel="noopener noreferrer"&gt;&lt;strong&gt;Should I learn React with TypeScript or JavaScript?&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I see these posts all the time—and honestly, it breaks my heart 🥲&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you’re a React dev still using JavaScript, you’re making your life harder.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The time you spend learning TypeScript will 100% pay off in the time you save debugging weird bugs.&lt;/p&gt;

&lt;p&gt;So here’s a guide to help you make the switch.&lt;/p&gt;

&lt;p&gt;Just the essentials. No fluff 😉.&lt;/p&gt;




&lt;h2&gt;
  
  
  How TypeScript works
&lt;/h2&gt;

&lt;p&gt;TypeScript adds extra syntax on top of JavaScript to help catch errors early—before they crash your app.&lt;/p&gt;

&lt;p&gt;It compiles to JavaScript in the end.&lt;/p&gt;

&lt;p&gt;The best part? &lt;strong&gt;You can slowly migrate to TypeScript.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Follow this &lt;a href="https://github.com/Microsoft/TypeScript-React-Conversion-Guide#typescript-react-conversion-guide" rel="noopener noreferrer"&gt;guide&lt;/a&gt; for more.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why you should switch to TypeScript ASAP
&lt;/h2&gt;

&lt;p&gt;Here’s why I think it’s a no-brainer:&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefit #1: Catch bugs &lt;em&gt;before&lt;/em&gt; they reach production
&lt;/h3&gt;

&lt;p&gt;This JavaScript code looks fine… until it explodes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;printFirstChar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;userIndex&lt;/span&gt;&lt;span class="p"&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;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;userIndex&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&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="mi"&gt;0&lt;/span&gt;&lt;span class="p"&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;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Fatou&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bob&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="nf"&gt;printFirstChar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ❌ Runtime error: Cannot read properties of undefined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here’s the TypeScript version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;printFirstChar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;users&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="nx"&gt;userIndex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&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;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;userIndex&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&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="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;TypeScript doesn’t fix your logic, but it gives you &lt;em&gt;early warnings&lt;/em&gt; like “hey, this might be undefined 👀”&lt;/p&gt;




&lt;h3&gt;
  
  
  Benefit #2: Get autocompletion with libraries
&lt;/h3&gt;

&lt;p&gt;Especially useful when you're exploring a new library.&lt;/p&gt;

&lt;p&gt;If that library has TypeScript types, you can get autocompletion inside most editors.&lt;/p&gt;




&lt;h3&gt;
  
  
  Benefit #3: Make your code more resilient to changes
&lt;/h3&gt;

&lt;p&gt;When you type things properly, TypeScript acts like a safety net.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;h4&gt;
  
  
  Without TypeScript, this code can break without you noticing.
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getLabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;switch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;idle&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Idle&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;loading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Loading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;success&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Success&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;getLabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;loading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ✅ works&lt;/span&gt;

&lt;span class="c1"&gt;// Months later...&lt;/span&gt;

&lt;span class="nf"&gt;getLabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;error&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ❌ returns undefined, but no JS error&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  With TypeScript, you need to handle changes.
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;idle&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;loading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;success&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getLabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Status&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="k"&gt;switch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;idle&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Idle&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;loading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Loading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;success&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Success&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;error&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Months later...&lt;/span&gt;
&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;idle&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;loading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;success&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;error&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// added 'error'&lt;/span&gt;

&lt;span class="c1"&gt;// ✅ TypeScript will show an error for the `getLabel` function: "Not all code paths return a value"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you forget to handle a case, TypeScript yells at you. And that’s precisely what you want 😄.&lt;/p&gt;

&lt;p&gt;TypeScript error when we forget to handle a case&lt;/p&gt;




&lt;h2&gt;
  
  
  The TypeScript concepts you need for React
&lt;/h2&gt;

&lt;p&gt;Let’s cover the &lt;strong&gt;bare minimum&lt;/strong&gt; to get started.&lt;/p&gt;




&lt;h3&gt;
  
  
  ✅ Types
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Types let you describe the shape of your data and enforce it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are native types in TypeScript, and types defined by users.&lt;/p&gt;

&lt;h4&gt;
  
  
  Native types
&lt;/h4&gt;

&lt;p&gt;These types come by default.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Ada&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// string&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// number&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;isActive&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// boolean&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;85&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt; &lt;span class="c1"&gt;// number[]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;💡 In some of the examples above, I typed values explicitly (like &lt;code&gt;const age: number = 31&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;You don’t need to do that in real code—TypeScript can infer the types by looking at the values.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Custom types
&lt;/h4&gt;

&lt;p&gt;You can create new types using the native types.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&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="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="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Fatou&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  ❌ Avoid &lt;code&gt;any&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Unless you’re in the middle of a migration, don’t use &lt;code&gt;any&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It’s JavaScript in disguise.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use&lt;/strong&gt; &lt;code&gt;unknown&lt;/code&gt; &lt;strong&gt;instead—it forces you to check the type before using it.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ❌ Bad: no warning, crashes at runtime&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;logLength&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;logLength&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;123&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// ✅ Safer&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;logLength&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// ✅✅ Better: use an explicit type&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;logLength&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;ArrayLike&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🧩 Union &amp;amp; intersection types
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Unions let a value be one of many types.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;idle&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;loading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;error&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;currentStatus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;idle&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Intersections combine multiple types into one.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Name&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="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Name&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;Age&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;person&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Person&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Ada&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🧱 Interfaces
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Interfaces define the structure of an object.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&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;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can extend interfaces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Admin&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;role&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When to use &lt;code&gt;type&lt;/code&gt; vs &lt;code&gt;interface&lt;/code&gt;? Doesn’t matter much.&lt;/p&gt;

&lt;p&gt;But here’s an interesting guide:&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://www.totaltypescript.com/type-vs-interface-which-should-you-use#default-to-type-not-interface" rel="noopener noreferrer"&gt;&lt;strong&gt;Type vs Interface: Which Should You Use?&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  🔁 Generics
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Generics let you write reusable types with flexible data.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s say you’re typing an API response.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Without generics:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;UserResponse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;error&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="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;ProductResponse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;error&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s a lot of repetition.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;With generics:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;ApiResponse&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;error&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="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;UserResponse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ApiResponse&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;User&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;type&lt;/span&gt; &lt;span class="nx"&gt;ProductResponse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ApiResponse&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Product&lt;/span&gt;&lt;span class="o"&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;You can use generics in functions too:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;wrap&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;wrap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// type: number[]&lt;/span&gt;
&lt;span class="nf"&gt;wrap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hi&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// type: string[]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I like to think of generics like function parameters—but for types 😉.&lt;/p&gt;




&lt;h3&gt;
  
  
  🔧 Function types
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;You can type function parameters and return values.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You always need to type the parameters, but don’t need to type the returned value every time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This works&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// This also works: you don't need to type the returned value&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// inferred as number&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also type the function variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Depending on the context, you may want to type the return type. &lt;strong&gt;When in doubt, type the return type.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can learn more about return types here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://mkosir.github.io/typescript-style-guide/#return-types" rel="noopener noreferrer"&gt;TypeScript Style Guide: Return Types&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.totaltypescript.com/tips/dont-use-return-types-unless" rel="noopener noreferrer"&gt;Don’t use return types, unless...&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  How to use TypeScript with React
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Props
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Props are just objects. Type them like any other object.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With &lt;code&gt;type&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;GreetingProps&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="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Greeting&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;GreetingProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Hello&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;code&gt;interface&lt;/code&gt; :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;GreetingProps&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&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="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Greeting&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;GreetingProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Hello&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  State
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;useState&lt;/code&gt; &lt;strong&gt;accepts a generic type, but TypeScript can also infer it.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// inferred as number&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But if it can’t, be explicit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&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;setUser&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&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="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Component variables and functions
&lt;/h3&gt;

&lt;p&gt;Just like normal TypeScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;[]&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Fatou&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="p"&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Bob&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&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;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// inferred as number&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you have some functions like event handlers, you can hover over the DOM elements to see the types to use.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleClick&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MouseEvent&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;HTMLButtonElement&lt;/span&gt;&lt;span class="o"&gt;&amp;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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Clicked!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// Or:&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleClick&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MouseEventHandler&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;HTMLButtonElement&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Clicked!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Re-using types across components
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;You can extend or combine types/interfaces to avoid duplication.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With interfaces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;ButtonProps&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;label&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="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;IconButtonProps&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;ButtonProps&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;icon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ReactNode&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With union types:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;ButtonProps&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;label&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="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;IconButtonProps&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ButtonProps&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;icon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ReactNode&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Hooks
&lt;/h3&gt;

&lt;p&gt;Hooks are just functions, so you can use the same TypeScript tools that apply to functions.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Native hooks&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Pretty much all the native hooks have generic params.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// or let TS infer:&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&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;inputRef&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useRef&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;HTMLInputElement&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useReducer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;inc&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dec&lt;/span&gt;&lt;span class="dl"&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="k"&gt;switch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;inc&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dec&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Custom hooks&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;useToggle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;initial&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;boolean&lt;/span&gt;&lt;span class="p"&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="k"&gt;void&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;initial&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;toggle&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="nf"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;prev&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;prev&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;toggle&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;isOpen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;toggleOpen&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useToggle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Where to learn more
&lt;/h2&gt;

&lt;p&gt;If you want to go deeper with TypeScript, here are some great resources to explore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;🧠 &lt;a href="https://www.typescriptlang.org/docs/handbook/intro.html" rel="noopener noreferrer"&gt;TypeScript Official Docs&lt;/a&gt;: The best place to start. It’s clear, well-structured, and packed with examples. Also includes a &lt;a href="https://www.typescriptlang.org/play" rel="noopener noreferrer"&gt;playground&lt;/a&gt; to test things out.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🎯 &lt;a href="https://www.totaltypescript.com/" rel="noopener noreferrer"&gt;Total TypeScript&lt;/a&gt;: A fantastic site by Matt Pocock—especially for React devs.&lt;br&gt;&lt;br&gt;
It has a free beginner course, advanced patterns, and many real-world examples.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;✨ &lt;a href="https://mkosir.github.io/typescript-style-guide/" rel="noopener noreferrer"&gt;TypeScript Style Guide&lt;/a&gt;: Short, practical tips on how to write clean and consistent TypeScript code. Highly recommended once you start building real apps.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🧩 &lt;a href="https://github.com/type-challenges/type-challenges" rel="noopener noreferrer"&gt;Type Challenges&lt;/a&gt;: A collection of TypeScript puzzles—from beginner to insane. Great if you learn best by solving problems and want to flex your type system skills.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;📘 &lt;a href="https://effectivetypescript.com/" rel="noopener noreferrer"&gt;Effective TypeScript&lt;/a&gt;: A book + blog by Dan Vanderkam. More advanced, but teaches you how to write &lt;em&gt;better&lt;/em&gt; TypeScript. Worth it once you know the basics.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;⚛️ &lt;a href="https://react-typescript-cheatsheet.netlify.app/" rel="noopener noreferrer"&gt;React TypeScript Cheatsheets&lt;/a&gt;: Tailored for React devs. Covers everything from typing components to context and hooks. Very beginner-friendly, and super helpful as a quick reference.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 Make sure to also check out the &lt;a href="https://dev.to/_ndeyefatoudiop/101-react-tips-tricks-for-beginners-to-experts-4m11#category-12-react-amp-typescript"&gt;TypeScript section&lt;/a&gt; of my 101 React Tips &amp;amp; Tricks post 😉.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Using TypeScript with React is one of the best upgrades you can make.&lt;/p&gt;

&lt;p&gt;It helps you &lt;strong&gt;catch bugs early&lt;/strong&gt;, gives you &lt;strong&gt;better tooling&lt;/strong&gt;, and makes your code &lt;strong&gt;easier to maintain&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The best part? &lt;strong&gt;You don’t need to learn everything up front.&lt;/strong&gt; Start with the basics—types, interfaces, generics—and grow from there.&lt;/p&gt;

&lt;p&gt;Many examples are online if you get stuck, and AI tools can help you unblock fast.&lt;/p&gt;

&lt;p&gt;Let me know if you have any questions 🙂.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;iframe&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://embeds.beehiiv.com/4b52f101-5150-4e42-abc6-28785fdd68cd"&lt;/span&gt; &lt;span class="na"&gt;data-test-id=&lt;/span&gt;&lt;span class="s"&gt;"beehiiv-embed"&lt;/span&gt; &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;"100%"&lt;/span&gt; &lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;"320"&lt;/span&gt; &lt;span class="na"&gt;frameborder=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt; &lt;span class="na"&gt;scrolling=&lt;/span&gt;&lt;span class="s"&gt;"no"&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"border-radius: 4px; border: 2px solid #e5e7eb; margin: 0; background-color: transparent;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;That's a wrap 🎉.&lt;/p&gt;

&lt;p&gt;Leave a comment 📩 to join the discussion.&lt;/p&gt;

&lt;p&gt;And don't forget to drop a "💖🦄🔥".&lt;/p&gt;

&lt;p&gt;If you're learning React, download my &lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" rel="noopener noreferrer"&gt;101 React Tips &amp;amp; Tricks book&lt;/a&gt; for &lt;strong&gt;FREE&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you like articles like this, join my &lt;strong&gt;FREE&lt;/strong&gt; newsletter, &lt;strong&gt;&lt;a href="https://frontendjoy.com/" rel="noopener noreferrer"&gt;FrontendJoy&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you want daily tips, find me on &lt;a href="https://twitter.com/_ndeyefatoudiop" rel="noopener noreferrer"&gt;X/Twitter&lt;/a&gt; or &lt;a href="https://bsky.app/profile/ndeyefatoudiop.bsky.social" rel="noopener noreferrer"&gt;Bluesky&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>react</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Why Junior Developers Must Seize Control of Their Growth Journey Today</title>
      <dc:creator>Ndeye Fatou Diop</dc:creator>
      <pubDate>Thu, 10 Apr 2025 07:00:00 +0000</pubDate>
      <link>https://dev.to/_ndeyefatoudiop/why-junior-developers-must-seize-control-of-their-growth-journey-today-5ac2</link>
      <guid>https://dev.to/_ndeyefatoudiop/why-junior-developers-must-seize-control-of-their-growth-journey-today-5ac2</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj41dn1q8uh26vpnv9r90.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj41dn1q8uh26vpnv9r90.png" alt="AI-generated image showing a woman at a crossroads" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3 years ago, I found myself at a crossroads.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I was enjoying the work and the learnings, &lt;strong&gt;but&lt;/strong&gt; I couldn’t clearly articulate my impact—or even tell if I was heading in the right direction.&lt;/p&gt;

&lt;p&gt;I was doing the work I was asked to do, going with the flow, not questioning anything.&lt;/p&gt;

&lt;p&gt;After some reflection, I realized I &lt;em&gt;did&lt;/em&gt; want to grow—both financially and technically—but my current actions wouldn’t get me there.&lt;/p&gt;

&lt;p&gt;That’s when I saw I was making the &lt;strong&gt;same mistake most juniors&lt;/strong&gt; make:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Not owning your growth and just letting things be.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Fast forward a few months, I became the go-to dev for a product and started making real career progress.&lt;/p&gt;

&lt;p&gt;In this post, I’ll share:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Why it’s important to own your growth&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Why it’s so tempting to fall into the trap&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;And what you can do about it&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Let’s dive in 👇&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  What it means to own your career growth
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk17b8rpgi5zfpkopwfr7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk17b8rpgi5zfpkopwfr7.png" alt="AI-generated image showing a person climbing a staircase made of sticky notes or stepping stones labeled “Goal,” “Skills,” “Feedback,” “Growth.”" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When I say “own your career growth,” I mean:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Being intentional about your work and whether it’s taking you where you want to go&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Advocating for yourself—sharing your goals and expectations&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Having a rough vision of where you want to be in 1, 3, 5, or even 10 years&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, let’s look at &lt;em&gt;why&lt;/em&gt; this matters.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why it’s important to own your career growth
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frjgkc0bj8bl0cxmodnl9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frjgkc0bj8bl0cxmodnl9.png" alt="AI-generated image showing a superhero version of a dev tearing open a shirt with a glowing " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Reason #1: Only &lt;em&gt;you&lt;/em&gt; know what you truly need
&lt;/h3&gt;

&lt;p&gt;Even with the best manager in the world, only you know what drives you.&lt;/p&gt;

&lt;p&gt;Is it more pay? More ownership? More technical challenge?&lt;/p&gt;

&lt;p&gt;Everyone’s different. So your version of growth will look different than your colleague’s.&lt;/p&gt;

&lt;p&gt;You have to own that. No one else will.&lt;/p&gt;




&lt;h3&gt;
  
  
  Reason #2: “If you don't have a plan, you become part of somebody else's plan.”
&lt;/h3&gt;

&lt;p&gt;The more you say “yes,” the more you risk ending up on projects that don’t serve you long-term.&lt;/p&gt;

&lt;p&gt;Unless you &lt;em&gt;want&lt;/em&gt; to be a “yes” person—which is totally valid 🙂—have opinions about where you want to grow.&lt;/p&gt;

&lt;p&gt;Because if you don’t have a plan, rest assured you’ll be helping execute someone else’s. And that might not be what you want.&lt;/p&gt;




&lt;h3&gt;
  
  
  Reason #3: Goals make the journey more satisfying
&lt;/h3&gt;

&lt;p&gt;I &lt;em&gt;thrive&lt;/em&gt; on setting goals and reaching them.&lt;/p&gt;

&lt;p&gt;It gives me a sense of progress. A feeling that I’m getting better.&lt;/p&gt;

&lt;p&gt;But that feeling disappears if all I do is jump from project to project with no cohesion.&lt;/p&gt;

&lt;p&gt;And work becomes... meh 🤣.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why you might not be owning your growth (yet)
&lt;/h2&gt;

&lt;p&gt;Especially early on, it’s easy to fall into one of these traps:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5anlw4wce5sxa0rormg9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5anlw4wce5sxa0rormg9.png" alt="AI-generated image showing a developer snoozing at a desk while opportunities (represented by rockets or paths) fly past in the background." width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Trap #1: You're just happy to be here
&lt;/h3&gt;

&lt;p&gt;When I landed my first dev job, I was blown away—getting paid &lt;em&gt;that much&lt;/em&gt; for work I mostly enjoyed? Wild.&lt;/p&gt;

&lt;p&gt;I got &lt;strong&gt;comfortable&lt;/strong&gt;. Too comfortable. I wasn’t pushing myself or questioning the work.&lt;/p&gt;

&lt;p&gt;But eventually, I realized:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Progress is important.&lt;br&gt;&lt;br&gt;
Especially progress in the &lt;em&gt;right&lt;/em&gt; direction.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If your work feels disconnected, it’s hard to tell what you’re becoming great at—or what makes you unique.&lt;/p&gt;

&lt;p&gt;Once the joy of simply “being in tech” disappears, start thinking about your next milestones.&lt;/p&gt;




&lt;h3&gt;
  
  
  Trap #2: You think learning = progress
&lt;/h3&gt;

&lt;p&gt;If you want to explore and learn as much as possible, that’s 100% valid. That’s a plan in itself.&lt;/p&gt;

&lt;p&gt;But don’t confuse learning with progress.&lt;/p&gt;

&lt;p&gt;You can know everything in the world—but if you’re not applying it in ways that move the business or your career forward, that knowledge won’t help much.&lt;/p&gt;

&lt;p&gt;To &lt;em&gt;grow&lt;/em&gt; (especially in pay), you must build &lt;strong&gt;deep expertise&lt;/strong&gt; in something.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/T-shaped_skills" rel="noopener noreferrer"&gt;T-shaped skills&lt;/a&gt; are a great model here.&lt;/p&gt;




&lt;h3&gt;
  
  
  Trap #3: You don’t know what’s possible
&lt;/h3&gt;

&lt;p&gt;Good news—this one’s easy to fix.&lt;/p&gt;

&lt;p&gt;You can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Talk to role models&lt;/strong&gt; in your company. Ask how they got where they are. Or just watch them closely.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ask your manager&lt;/strong&gt; about growth paths that align with your strengths.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Start with life goals.&lt;/strong&gt; Need to buy a house? Pay for kids’ school? Cool—reverse-engineer what you’ll need in skills, roles, and pay to get there.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  How to start owning your growth
&lt;/h2&gt;

&lt;p&gt;Here’s what worked for me when I decided to become a major actor in my career 😅:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1oaljemn8vhpehmzjsnr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1oaljemn8vhpehmzjsnr.png" alt="AI-generated image showing a pen in someone’s hand, writing their story, with a caption bubble: “Write your own story.”" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Step #1: Set goals
&lt;/h3&gt;

&lt;p&gt;Set &lt;a href="https://www.notion.so/How-to-level-up-your-frontend-skills-13ab7b09cb268044b773fb845d2623aa?pvs=21" rel="noopener noreferrer"&gt;SMART&lt;/a&gt; goals—specific, measurable, and realistic.&lt;/p&gt;

&lt;p&gt;I had a simple written goal: &lt;em&gt;Become the go-to dev for this product&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Fast forward to today, I am the dev lead for that product.&lt;/p&gt;

&lt;p&gt;Having that goal gave me clarity and direction.&lt;/p&gt;




&lt;h3&gt;
  
  
  Step #2: Track your progress
&lt;/h3&gt;

&lt;p&gt;Without tracking, goals are just dreams.&lt;/p&gt;

&lt;p&gt;Make sure you’re doing &lt;em&gt;something&lt;/em&gt; each day that moves you toward them.&lt;/p&gt;




&lt;h3&gt;
  
  
  Step #3: Share your goals
&lt;/h3&gt;

&lt;p&gt;Let your manager and teammates know what you’re aiming for.&lt;/p&gt;

&lt;p&gt;They can’t help you if they don’t know what you care about.&lt;/p&gt;

&lt;p&gt;Once you share your goals, people will start forwarding you the right projects—and stop handing you stuff that doesn't align.&lt;/p&gt;




&lt;h3&gt;
  
  
  Step #4: Evaluate tasks through your goals
&lt;/h3&gt;

&lt;p&gt;Now that you know where you’re headed, filter your tasks through that lens.&lt;/p&gt;

&lt;p&gt;If something doesn’t move you closer, either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Delegate it&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Or knock it out quickly and move on&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Step #5: Take initiative when the path isn’t clear
&lt;/h3&gt;

&lt;p&gt;Sometimes, no task or project helps you grow in the way you want.&lt;/p&gt;

&lt;p&gt;That’s okay.&lt;/p&gt;

&lt;p&gt;But &lt;strong&gt;don’t stay stuck&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Push for new projects or initiatives&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Switch to a better-fit team&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Or, if needed, change companies entirely&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Step #6: Copy what works
&lt;/h3&gt;

&lt;p&gt;Working with great colleagues? Lucky you.&lt;/p&gt;

&lt;p&gt;Watch them. Steal Copy their playbook.&lt;/p&gt;

&lt;p&gt;If someone’s doing what you want to be doing, study how they act, what they prioritize, and how they communicate.&lt;/p&gt;

&lt;p&gt;Then try those things at your level.&lt;/p&gt;

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




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;If you landed a job in tech—congrats 🎉&lt;br&gt;&lt;br&gt;
You earned it.&lt;/p&gt;

&lt;p&gt;But &lt;strong&gt;don’t get stuck in “grateful mode.”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Don’t use that as an excuse to take every task, say yes to everything, or never question the direction you're headed in.&lt;/p&gt;

&lt;p&gt;Be intentional. Be strategic. Own where your day is taking you.&lt;/p&gt;

&lt;p&gt;Because especially in a world with AI and layoffs, you don’t want to wake up one day and realize you weren’t building the right skills.&lt;/p&gt;

&lt;p&gt;Remember:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;“When writing the story of your life, don't let anyone else hold the pen.”&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>webdev</category>
      <category>career</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How I Reduced My React Bundle Size by 30% (With Real Examples)</title>
      <dc:creator>Ndeye Fatou Diop</dc:creator>
      <pubDate>Mon, 07 Apr 2025 13:50:00 +0000</pubDate>
      <link>https://dev.to/_ndeyefatoudiop/how-i-reduced-my-react-bundle-size-by-30-with-real-examples-12ff</link>
      <guid>https://dev.to/_ndeyefatoudiop/how-i-reduced-my-react-bundle-size-by-30-with-real-examples-12ff</guid>
      <description>&lt;p&gt;&lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" class="crayons-btn crayons-btn--primary" rel="noopener noreferrer"&gt;📚 Download my FREE 101 React Tips And Tricks Book for a head start.&lt;/a&gt;
&lt;/p&gt;




&lt;p&gt;Ever had this happen?&lt;/p&gt;

&lt;p&gt;You start building a new frontend app.&lt;/p&gt;

&lt;p&gt;Everything is fast. Production builds take seconds. Users are happy 🥰.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But as time goes on…&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Build times start to drag.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The app feels slower.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Users complain.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You’re unsure why — you’ve just been writing “normal” code.&lt;/p&gt;

&lt;p&gt;What’s going on?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;99% of the time, it’s because your bundle size spiraled out of control.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this post, I’ll show you &lt;strong&gt;7 proven ways&lt;/strong&gt; to reduce bundle size and speed up your builds — with a real demo you can try.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚡️ Before vs After
&lt;/h2&gt;

&lt;p&gt;By the end of this guide, we will go from:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;📦 283.39 kB → 198.33 kB&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That’s a &lt;strong&gt;30%+ size reduction&lt;/strong&gt;, just by applying simple tips.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ Setup
&lt;/h2&gt;

&lt;p&gt;For this demo, I built a React app (generated with &lt;a href="https://v0.dev/" rel="noopener noreferrer"&gt;V0&lt;/a&gt;) available on GitHub:&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://github.com/nfdiop/demo_react_app" rel="noopener noreferrer"&gt;GitHub repo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3tjvw8su32duqnwtsdfr.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3tjvw8su32duqnwtsdfr.gif" alt="Demo Application"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Key details:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Run &lt;code&gt;npm run build&lt;/code&gt; to bundle the app for production.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Each optimization step has a dedicated branch (&lt;code&gt;step-1-remove-side-effects&lt;/code&gt;, &lt;code&gt;step-2-remove-unused-files-packages&lt;/code&gt;, etc.).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;a href="https://github.com/nfdiop/demo_react_app" rel="noopener noreferrer"&gt;main&lt;/a&gt; branch contains the &lt;strong&gt;unoptimized&lt;/strong&gt; version, and the fully &lt;strong&gt;optimized&lt;/strong&gt; code is in the &lt;a href="https://github.com/nfdiop/demo_react_app/tree/step-7-lazy-load-components" rel="noopener noreferrer"&gt;step-7-lazy-load-components&lt;/a&gt; branch.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;Note&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;- Each step builds on the previous one: branch &lt;code&gt;step-3-…&lt;/code&gt; includes fixes from &lt;code&gt;step-1-…&lt;/code&gt; and &lt;code&gt;step-2-…&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;- I’m using global CSS here (for speed). In real apps, prefer CSS Modules or tools like &lt;a href="https://tailwindcss.com/" rel="noopener noreferrer"&gt;Tailwind&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Tooling
&lt;/h3&gt;

&lt;p&gt;I used &lt;a href="https://www.npmjs.com/package/vite-bundle-analyzer" rel="noopener noreferrer"&gt;vite-bundle-analyzer&lt;/a&gt; to visualize bundle contents.&lt;/p&gt;

&lt;p&gt;Here’s the initial bundle from the &lt;code&gt;main&lt;/code&gt; branch:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F48hazugl95uz3tv0gj4x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F48hazugl95uz3tv0gj4x.png" alt="Bundle graph generated on main branch"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Step #1: Eliminate Side Effects in Files
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;👉&lt;/strong&gt; &lt;a href="https://github.com/nfdiop/demo_react_app/pull/2/files" rel="noopener noreferrer"&gt;&lt;strong&gt;Code changes&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Bundlers rely on tree-shaking to exclude unused code from the final bundle—&lt;strong&gt;unless a file has side effects&lt;/strong&gt; (see &lt;a href="https://www.frontendjoy.com/p/module-bundlers-demystified-what-you-actually-need-to-know#benefit-3-it-optimizes-the-size-of-" rel="noopener noreferrer"&gt;#Benefit 3&lt;/a&gt; in my post about bundlers).&lt;/p&gt;

&lt;p&gt;Side effects (like modifying the &lt;code&gt;window&lt;/code&gt; object) force the bundler to include the file, even if unused.&lt;/p&gt;

&lt;p&gt;🧪 &lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In our demo, the file &lt;a href="https://github.com/nfdiop/demo_react_app/blob/a014a4f99ee59051da6e2381889c68891a253cf3/src/components/HelloWorld/HelloWorld.jsx#L1" rel="noopener noreferrer"&gt;HelloWorld.js&lt;/a&gt; contains a side effect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;someBadSideEffect&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I'm a side effect and I will be included inside the bundle even if not used&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Even though the file isn’t used, its code appears in the bundle file (&lt;code&gt;dist/assets/index-[hash].js&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Remove the side effect. The file is now excluded from the bundle.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft75c24ery2sy2qmuso3w.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft75c24ery2sy2qmuso3w.gif" alt="Demo opening the final bundle file and showing the side effect code"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fts90o8480bmmxknkkl74.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fts90o8480bmmxknkkl74.png" alt="Image of the final bundle file without the side effect"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Step #2: Hunt Down Unused Files &amp;amp; Packages
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;👉&lt;/strong&gt; &lt;a href="https://github.com/nfdiop/demo_react_app/pull/3" rel="noopener noreferrer"&gt;&lt;strong&gt;Code changes&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unused files/packages &lt;em&gt;usually&lt;/em&gt; don’t bloat your bundle—but they:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Slow down bundling (more files to process).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Risk breaking tree-shaking (if they contain side effects).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Tool Recommendation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run &lt;a href="https://knip.dev/" rel="noopener noreferrer"&gt;npx knip&lt;/a&gt; or &lt;a href="https://www.npmjs.com/package/depcheck" rel="noopener noreferrer"&gt;npx depcheck&lt;/a&gt; to detect dead code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In our demo:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;HelloWorld.js&lt;/code&gt; and &lt;code&gt;lodash-es&lt;/code&gt; were flagged as unused.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After removing them, the &lt;strong&gt;number of&lt;/strong&gt; &lt;strong&gt;modules processed dropped from 44 to 42&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The impact would be more significant in more complex applications, and your app will build even faster ⚡️.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6v6m0qi85xd05upbvtda.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6v6m0qi85xd05upbvtda.png" alt="Results of running npx knip"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Facwy10ologtzca7ntjwt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Facwy10ologtzca7ntjwt.png" alt="The build results before/after the removal"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Step #3: Avoid Barrel Files
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;👉&lt;/strong&gt; &lt;a href="https://github.com/nfdiop/demo_react_app/pull/4" rel="noopener noreferrer"&gt;&lt;strong&gt;Code changes&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Barrel files (like &lt;a href="https://github.com/nfdiop/demo_react_app/blob/main/src/components/index.js" rel="noopener noreferrer"&gt;src/components/index.js&lt;/a&gt;) consolidate exports for cleaner imports:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Dashboard&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;UserManagement&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Settings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Clock&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./components&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But they introduce downsides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Side effects propagate:&lt;/strong&gt; If any exported file has side effects, the bundler can include it. This is why the side effects were present in Step #1.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;More files to process:&lt;/strong&gt; The module bundler will have to process more (or even irrelevant files if someone forgot to delete them). This results in slower builds.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In my demo app, I removed all the barrels in the &lt;code&gt;step-3-remove-barrel-files&lt;/code&gt; branch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt;: The number of modules transformed went from &lt;strong&gt;42 → 37&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhudr6i1ewp4eqn287nvp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhudr6i1ewp4eqn287nvp.png" alt="The build results before/after removing barrel files"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Step #4: Export Functions Directly, Not Objects/Classes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;👉&lt;/strong&gt; &lt;a href="https://github.com/nfdiop/demo_react_app/pull/1" rel="noopener noreferrer"&gt;&lt;strong&gt;Code changes&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you export an object or class, &lt;strong&gt;all its methods&lt;/strong&gt; are bundled—even unused ones.&lt;/p&gt;

&lt;p&gt;In our demo app, the &lt;a href="https://github.com/nfdiop/demo_react_app/blob/main/src/utils/time.js" rel="noopener noreferrer"&gt;time.js&lt;/a&gt; file exports a utility object, but only &lt;code&gt;getTimeInFormat&lt;/code&gt; is used. Yet, the entire object landed in the bundle.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fie77n1rgut44sctmxc2r.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fie77n1rgut44sctmxc2r.jpg" alt="Before: The bundle file with the unused methods"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Export functions individually. Now, unused utilities are stripped automatically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; There is a slight decrease in the bundle size.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmwadtvxj93cwgqde1opi.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmwadtvxj93cwgqde1opi.jpg" alt="After: The bundle file without unused functions"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Step #5: Swap Heavy Libraries for Lighter Alternatives
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;👉&lt;/strong&gt; &lt;a href="https://github.com/nfdiop/demo_react_app/pull/5/files" rel="noopener noreferrer"&gt;&lt;strong&gt;Code changes&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a big one.&lt;/p&gt;

&lt;p&gt;In the demo app, I used &lt;a href="https://momentjs.com/" rel="noopener noreferrer"&gt;moment.js&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But if you check &lt;a href="https://bundlephobia.com/package/moment@2.30.1" rel="noopener noreferrer"&gt;Bundlephobia&lt;/a&gt;, you’ll see it’s huge.&lt;/p&gt;

&lt;p&gt;A better choice? &lt;a href="https://day.js.org/" rel="noopener noreferrer"&gt;dayjs&lt;/a&gt; — smaller and modern.&lt;/p&gt;

&lt;p&gt;Swapping &lt;code&gt;moment&lt;/code&gt; for &lt;code&gt;dayjs&lt;/code&gt; gives you an instant bundle size drop.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pro tip:&lt;/strong&gt; Also check for ESM support—it helps with tree-shaking.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk8icnoeacsrp27v9rhky.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk8icnoeacsrp27v9rhky.jpg" alt="Bundle graph with moment.js"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fju7gukhhlib3zcur0ouk.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fju7gukhhlib3zcur0ouk.jpg" alt="Bundle graph with dayjs"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fed4pba1y5zhpnicsagea.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fed4pba1y5zhpnicsagea.png" alt="The build results before/after removing moment.js"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Step #6: Lazy-Load Non-Critical Packages
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;👉&lt;/strong&gt; &lt;a href="https://github.com/nfdiop/demo_react_app/pull/6" rel="noopener noreferrer"&gt;&lt;strong&gt;Code changes&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If a package isn’t needed immediately, don’t load it at startup.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
I use &lt;a href="https://www.fusejs.io/" rel="noopener noreferrer"&gt;Fuse.js&lt;/a&gt; for fuzzy search, but only when the user starts typing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Instead of importing it statically, I load it when needed using &lt;a href="https://javascript.info/modules-dynamic-imports" rel="noopener noreferrer"&gt;dynamic imports&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Lazy load Fuse.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Fuse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fuse.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; &lt;code&gt;fuse.js&lt;/code&gt; splits into a separate chunk, reducing the initial load.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmfnz2958ut5h4nfwkvid.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmfnz2958ut5h4nfwkvid.jpg" alt="Before: Bundle graph with fuse.js used directly"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4surqnw4yfzcrib87npk.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4surqnw4yfzcrib87npk.jpg" alt="After: Bundle graph with fuse.js imported dynamically"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fciq5dc42bbrhmqaivw2t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fciq5dc42bbrhmqaivw2t.png" alt="The build results before/after importing fuse.js dynamically"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Step #7: [React] Lazy-Load Non-Critical Components
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;👉&lt;/strong&gt; &lt;a href="https://github.com/nfdiop/demo_react_app/pull/7" rel="noopener noreferrer"&gt;&lt;strong&gt;Code changes&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Same idea — if components aren’t needed at startup, &lt;strong&gt;don’t load them immediately&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In my demo, files like &lt;a href="https://github.com/nfdiop/demo_react_app/blob/main/src/components/Dashboard/Dashboard.jsx" rel="noopener noreferrer"&gt;Dashboard.jsx&lt;/a&gt; and &lt;a href="https://github.com/nfdiop/demo_react_app/blob/main/src/components/Settings/Settings.jsx" rel="noopener noreferrer"&gt;Settings.jsx&lt;/a&gt; are only required when the user clicks a button.&lt;/p&gt;

&lt;p&gt;So I lazy-load them using &lt;a href="https://react.dev/reference/react/lazy" rel="noopener noreferrer"&gt;React.lazy&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Settings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;lazy&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
  &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./components/Settings&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;module&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="na"&gt;default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Settings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}))&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; A smaller initial bundle, which results in faster first load of your app.&lt;/p&gt;




&lt;h2&gt;
  
  
  Bonus 🪄
&lt;/h2&gt;

&lt;p&gt;A few more ideas you could explore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Add &lt;code&gt;"sideEffects": false&lt;/code&gt; in &lt;code&gt;package.json&lt;/code&gt; to improve tree-shaking&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use &lt;a href="https://www.npmjs.com/package/bundlewatch" rel="noopener noreferrer"&gt;Bundlewatch&lt;/a&gt; or &lt;a href="https://github.com/ai/size-limit" rel="noopener noreferrer"&gt;Size Limit&lt;/a&gt; to monitor size in CI&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enable more code-splitting or compression with Vite plugins&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ✅ Cheatsheet
&lt;/h2&gt;

&lt;p&gt;Quick recap of everything we did:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;✅ Remove side effects from files  
✅ Delete unused files and packages  
✅ Avoid barrel files  
✅ Export functions directly  
✅ Use smaller libraries (dayjs &amp;gt; moment)  
✅ Lazy-load heavy packages  
✅ Lazy-load components 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;👉&lt;/strong&gt; &lt;a href="https://github.com/nfdiop/demo_react_app/compare/main...step-7-lazy-load-components" rel="noopener noreferrer"&gt;&lt;strong&gt;Code changes&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Frontend apps often get slower over time — even without adding “heavy” code.&lt;/p&gt;

&lt;p&gt;But if you apply these tips regularly, you can &lt;strong&gt;stay fast&lt;/strong&gt;, keep build times short, and make life easier for your team and users.&lt;/p&gt;

&lt;p&gt;Got other tips? I'd love to hear them 🙂.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;That's a wrap 🎉.&lt;/p&gt;

&lt;p&gt;Leave a comment 📩 to share more tips.&lt;/p&gt;

&lt;p&gt;And don't forget to drop a "💖🦄🔥".&lt;/p&gt;

&lt;p&gt;If you're learning React, download my &lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" rel="noopener noreferrer"&gt;101 React Tips &amp;amp; Tricks book&lt;/a&gt; for &lt;strong&gt;FREE&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you like articles like this, join my &lt;strong&gt;FREE&lt;/strong&gt; newsletter, &lt;strong&gt;&lt;a href="https://frontendjoy.com/" rel="noopener noreferrer"&gt;FrontendJoy&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you want daily tips, find me on &lt;a href="https://twitter.com/_ndeyefatoudiop" rel="noopener noreferrer"&gt;X/Twitter&lt;/a&gt; or &lt;a href="https://bsky.app/profile/ndeyefatoudiop.bsky.social" rel="noopener noreferrer"&gt;Bluesky&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
      <category>beginners</category>
    </item>
    <item>
      <title>✨ Your Manager Should Never Have to Ping You</title>
      <dc:creator>Ndeye Fatou Diop</dc:creator>
      <pubDate>Sun, 16 Mar 2025 13:37:58 +0000</pubDate>
      <link>https://dev.to/_ndeyefatoudiop/your-manager-should-never-have-to-ping-you-f92</link>
      <guid>https://dev.to/_ndeyefatoudiop/your-manager-should-never-have-to-ping-you-f92</guid>
      <description>&lt;p&gt;On my first work assignment, I thought I was doing great work 😎.&lt;/p&gt;

&lt;p&gt;I was talking to customers, handling their requirements, making them happy, etc.&lt;/p&gt;

&lt;p&gt;However, to my surprise, &lt;strong&gt;my manager didn’t share my point of view&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;She didn’t realize all the work I was doing and couldn’t articulate the value I was providing.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I was pretty shocked. I thought my work was speaking for itself.&lt;/p&gt;

&lt;p&gt;We agreed that I would post a daily update in the team chat to keep them informed. I still didn’t see the need.&lt;/p&gt;

&lt;p&gt;But hey, why not?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fast forward to today&lt;/strong&gt;—as a team lead, I totally get it 😅.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If I don’t hear from a junior dev on my team regularly, I start getting slightly worried that things are going wrong.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Even with meetings, it’s impossible to have an accurate picture of what everyone is doing unless they communicate it.&lt;/p&gt;

&lt;p&gt;In this post, I’ll share why you must over-communicate as a junior dev—and how to do it properly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" class="ltag_cta ltag_cta--branded" rel="noopener noreferrer"&gt;📚 Download my FREE 101 React Tips And Tricks Book for a head start.&lt;/a&gt;
&lt;/p&gt;




&lt;h2&gt;
  
  
  What Happens When You Don’t Over-Communicate
&lt;/h2&gt;

&lt;p&gt;Imagine you ask your younger sibling (3-4 years old) to help you with something.&lt;/p&gt;

&lt;p&gt;They’ve never done it before and have no experience.&lt;/p&gt;

&lt;p&gt;How would you feel if they stayed silent the whole day?&lt;/p&gt;

&lt;p&gt;Chances are, you’d feel uneasy—scared they might be doing something completely wrong (and your mom will kill you 😅).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Having a junior dev on the team can feel the same way&lt;/strong&gt; 😅&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As mentors, our responsibilities are to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Make sure they are doing as well as they can&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Prevent them from going down rabbit holes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ensure they don’t make mistakes and try to fix them in silence&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So &lt;strong&gt;when a junior dev doesn’t communicate progress often, something feels off.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As a junior dev:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You should have multiple questions daily.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You should encounter blockers (and ask for help).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You should share progress frequently.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even if you’re amazing and don’t need help, you should communicate progress at least twice daily (personal preference).&lt;/p&gt;

&lt;p&gt;If you don’t, your mentors will feel stressed or have to ping you regularly.&lt;/p&gt;

&lt;p&gt;As a &lt;strong&gt;rule of thumb: After the first few weeks, no one should have to ask you for status updates.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  How to Over-Communicate Properly
&lt;/h2&gt;

&lt;p&gt;This is as easy as it gets.&lt;/p&gt;

&lt;p&gt;It depends on your circumstances:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If you sit next to your manager or team lead, &lt;strong&gt;talk to them periodically&lt;/strong&gt;—ask questions, provide status updates, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you’re remote, &lt;strong&gt;send updates using your team’s communication channels&lt;/strong&gt; (Slack, messages, etc.).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As a junior dev staffed on a task, you should:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Clarify how long the task is expected to take&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Work your best to meet expectations by asking for help when needed&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you can &lt;strong&gt;split your task into smaller steps&lt;/strong&gt;, that would be even better. This will clearly show that you’re actively working and making progress.&lt;/p&gt;

&lt;p&gt;In general, communicate with your manager about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Anything wrong—even if it’s not your fault (e.g., issues caused by another team that impact your work)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Anything blocking or bothering you&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Communication doesn’t always have to be written.&lt;/strong&gt; Opening pull requests and writing code are also ways to show progress.&lt;/p&gt;

&lt;p&gt;Over time, you’ll have to communicate less because your manager will trust that you can work independently.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Caveat:&lt;/strong&gt; My advice applies to someone in a &lt;strong&gt;healthy team&lt;/strong&gt;—which has been my case for the past six years at Palantir. If that’s not your case, frequent questions may not be welcomed.&lt;/p&gt;

&lt;p&gt;However, you should still communicate your progress regularly, even if it’s just: &lt;em&gt;“I’m blocked by A and B, but I’m currently doing X and Y to get unblocked.”&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Your Challenge This Week:
&lt;/h2&gt;

&lt;p&gt;If you’re a junior developer, evaluate how often your manager has to ping you for an update.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If they regularly ping you, start giving them updates before they ask.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If they don’t, that’s a good sign—but it could also mean they don’t want to be intrusive or don’t care.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Either way, make sure you share daily progress on your tasks.&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Even if you’re doing an excellent job as a junior dev, your main job is to &lt;strong&gt;reassure&lt;/strong&gt; your manager/team lead by over-communicating.&lt;/p&gt;

&lt;p&gt;Share updates as often as possible (at least twice daily).&lt;/p&gt;

&lt;p&gt;The more you do this, the more trust you’ll build. Over time, you’ll have to do it less frequently 😉.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider" width="800" height="41"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;That's a wrap 🎉.&lt;/p&gt;

&lt;p&gt;Leave a comment 📩 to keep the discussion going.&lt;/p&gt;

&lt;p&gt;And don't forget to drop a "💖🦄🔥".&lt;/p&gt;

&lt;p&gt;If you're learning React, download my &lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" rel="noopener noreferrer"&gt;101 React Tips &amp;amp; Tricks book&lt;/a&gt; for &lt;strong&gt;FREE&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you like articles like this, join my &lt;strong&gt;FREE&lt;/strong&gt; newsletter, &lt;strong&gt;&lt;a href="https://frontendjoy.com/" rel="noopener noreferrer"&gt;FrontendJoy&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you want daily tips, find me on &lt;a href="https://twitter.com/_ndeyefatoudiop" rel="noopener noreferrer"&gt;X/Twitter&lt;/a&gt; or &lt;a href="https://bsky.app/profile/ndeyefatoudiop.bsky.social" rel="noopener noreferrer"&gt;Bluesky&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  🍔 FOOD FOR THOUGHT
&lt;/h2&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1897195388924494128-854" src="https://platform.twitter.com/embed/Tweet.html?id=1897195388924494128"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1897195388924494128-854');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1897195388924494128&amp;amp;theme=dark"
  }



&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>career</category>
      <category>beginners</category>
    </item>
    <item>
      <title>✨ Module Bundlers, Demystified: What You Actually Need to Know</title>
      <dc:creator>Ndeye Fatou Diop</dc:creator>
      <pubDate>Mon, 24 Feb 2025 14:00:00 +0000</pubDate>
      <link>https://dev.to/_ndeyefatoudiop/module-bundlers-demystified-what-you-actually-need-to-know-1bc4</link>
      <guid>https://dev.to/_ndeyefatoudiop/module-bundlers-demystified-what-you-actually-need-to-know-1bc4</guid>
      <description>&lt;p&gt;When I first heard &lt;em&gt;module bundler&lt;/em&gt; as a front-end developer, I thought, &lt;em&gt;“What is that magic again?”&lt;/em&gt; 😅&lt;/p&gt;

&lt;p&gt;I remember trying to read about them or even use one, but I didn’t see the usefulness.&lt;/p&gt;

&lt;p&gt;All I knew was that every article recommended using module bundlers like Webpack—and setting them up was hell 🔥.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I later realized that they’re one of the most crucial parts of modern frontend development, and you absolutely need to understand them.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this post, I’ll share what I &lt;em&gt;wish&lt;/em&gt; I had known about module bundlers.&lt;/p&gt;

&lt;p&gt;Let’s get started. 🚀&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" class="ltag_cta ltag_cta--branded" rel="noopener noreferrer"&gt;📚 Download my FREE 101 React Tips And Tricks Book for a head start.&lt;/a&gt;
&lt;/p&gt;




&lt;h2&gt;
  
  
  First, what do module bundlers do?
&lt;/h2&gt;

&lt;p&gt;Let’s start with an example.&lt;/p&gt;

&lt;p&gt;For this post, I made a React app called &lt;code&gt;demo_bundling_esbuild&lt;/code&gt; (&lt;a href="https://github.com/nfdiop/demo-bundling-esbuild" rel="noopener noreferrer"&gt;Github code&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;It’s a simple app that displays my name, age, and other personal information. (I know it's it's a bit self-centered 😅)&lt;/p&gt;

&lt;p&gt;It uses &lt;a href="https://esbuild.github.io/" rel="noopener noreferrer"&gt;esbuild&lt;/a&gt; as a module bundler and is structured like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;project/
├── src/
│   ├── App.tsx
│   ├── index.tsx
│   ├── data.json
│   ├── utils.ts
│   └── constants.ts
├── index.html
├── build.js
└── package.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once I finished development, I needed to &lt;em&gt;build&lt;/em&gt; the app so I could have an &lt;code&gt;index.html&lt;/code&gt; file to load in the browser.&lt;/p&gt;

&lt;p&gt;This is roughly what the app looks like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgpqt8n5kf72c7b46zwtn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgpqt8n5kf72c7b46zwtn.png" alt="Demo Application Using Bundling" width="800" height="518"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  But then something interesting happens...
&lt;/h3&gt;

&lt;p&gt;When I open my &lt;a href="https://developer.chrome.com/docs/devtools/network" rel="noopener noreferrer"&gt;&lt;strong&gt;Network&lt;/strong&gt;&lt;/a&gt; tab, I don’t see the same files as in my code editor.&lt;/p&gt;

&lt;p&gt;I can see the &lt;code&gt;index.html&lt;/code&gt; file, but where are &lt;code&gt;App.tsx&lt;/code&gt;, &lt;code&gt;index.tsx&lt;/code&gt;, and &lt;code&gt;constants.ts&lt;/code&gt;? 🤷‍♀️&lt;/p&gt;

&lt;p&gt;Instead, I see a single file: &lt;code&gt;dist/bundle.js&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When I open it (see in this &lt;a href="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/adbemukdklc3yev62gxv.gif" rel="noopener noreferrer"&gt;gif link&lt;/a&gt;), I find the content of &lt;code&gt;App.tsx&lt;/code&gt;, &lt;code&gt;index.tsx&lt;/code&gt;, and &lt;code&gt;utils.ts&lt;/code&gt;—but in a weird/minified format.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffobfjti0idru3cccn5qj.jpg" alt="Bundle size content" width="800" height="502"&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  So, what happened?
&lt;/h3&gt;

&lt;p&gt;How did I go from &lt;strong&gt;5 files&lt;/strong&gt; (&lt;code&gt;index.tsx&lt;/code&gt;, &lt;code&gt;utils.ts&lt;/code&gt;, &lt;code&gt;constants.ts&lt;/code&gt;, &lt;code&gt;App.tsx&lt;/code&gt;, &lt;code&gt;data.json&lt;/code&gt;) to &lt;strong&gt;1 file (&lt;/strong&gt;&lt;code&gt;dist/bundle.js&lt;/code&gt;)?&lt;/p&gt;

&lt;p&gt;How did all these files turn into a single &lt;em&gt;big&lt;/em&gt; file?&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Bundling happened.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;My module bundler (esbuild) took all the &lt;code&gt;.ts&lt;/code&gt; and &lt;code&gt;.json&lt;/code&gt; files and compiled them into &lt;strong&gt;one&lt;/strong&gt; file: &lt;code&gt;dist/bundle.js&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;PS: You can find the configuration here 👉&lt;/em&gt; &lt;a href="https://github.com/nfdiop/demo-bundling-esbuild/blob/main/build.js" rel="noopener noreferrer"&gt;&lt;em&gt;build.js&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk5two4leo7d21g456u88.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk5two4leo7d21g456u88.jpg" alt="Bundling diagram" width="800" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  In summary:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Module bundlers&lt;/strong&gt; are tools that combine multiple files in your codebase into fewer files.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And this is amazing for several reasons.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why bundling is important
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Benefit #1. It ensures your dependencies load in the correct order&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If you’re using dependencies (i.e., &lt;a href="https://www.npmjs.com/" rel="noopener noreferrer"&gt;npm&lt;/a&gt; packages), you probably import them like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;partition&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;lodash-es&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;v4&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;uuidv4&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;uuid&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the past, these imports didn’t work in all browsers.&lt;/p&gt;

&lt;p&gt;Module bundlers solve this by ensuring that dependencies load correctly.&lt;/p&gt;

&lt;p&gt;For example, if &lt;em&gt;File A&lt;/em&gt; depends on &lt;em&gt;File B&lt;/em&gt;, which depends on &lt;em&gt;File C&lt;/em&gt;, the bundler makes sure all necessary files are present before execution.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Benefit #2. It reduces the number of HTTP requests&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Without bundling, every file would need to be loaded separately.&lt;/p&gt;

&lt;p&gt;Browsers &lt;strong&gt;limit&lt;/strong&gt; the number of parallel network requests, so for large apps, this could mean waiting &lt;strong&gt;minutes&lt;/strong&gt; (or even &lt;em&gt;hours&lt;/em&gt;) just for files to download and parse.&lt;/p&gt;

&lt;p&gt;Bundlers reduce the number of files (usually 1–2 for small apps), significantly &lt;strong&gt;speeding up&lt;/strong&gt; the loading process.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Benefit #3. It optimizes the size of your files&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Before bundling your files, module bundlers apply &lt;strong&gt;optimizations&lt;/strong&gt; to make them as small as possible.&lt;/p&gt;

&lt;p&gt;Some of the key optimizations include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;🌴 &lt;strong&gt;Tree-shaking&lt;/strong&gt;: If you import a package but don’t use it, the bundler doesn’t include it in the final bundle. The bundler only consists of the code needed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;✂️ &lt;strong&gt;Minification&lt;/strong&gt;: It removes unnecessary whitespace and comments and renames variables to make files smaller.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In our example app, I have a constant called &lt;code&gt;NOT_USED_CONSTANT&lt;/code&gt; that I am importing inside &lt;code&gt;index.tsx&lt;/code&gt; but not using. So it won’t be inside &lt;code&gt;bundle.js&lt;/code&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Benefit #4. It enables dynamic imports (a.k.a. code-splitting)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Let’s say part of your app is &lt;em&gt;only&lt;/em&gt; needed for specific users (e.g., a dashboard for logged-in users).&lt;/p&gt;

&lt;p&gt;You don’t want to load &lt;em&gt;everything&lt;/em&gt; upfront—you want to &lt;strong&gt;lazy-load&lt;/strong&gt; that code only when needed.&lt;/p&gt;

&lt;p&gt;You can tell your module bundler to &lt;em&gt;“put some piece of code&lt;/em&gt; &lt;em&gt;in a separate file and load it only when required.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When you do this, you increase your app speed 🚀 since there are fewer files to download.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Benefit #5. (Bonus) It supports different file types (.ts, .json, etc.)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;By default, bundlers work with JavaScript files.&lt;/p&gt;

&lt;p&gt;But they also support other formats (&lt;code&gt;.ts&lt;/code&gt;, &lt;code&gt;.json&lt;/code&gt;, &lt;code&gt;.jsx&lt;/code&gt;, etc.) using &lt;strong&gt;loaders (&lt;/strong&gt;&lt;a href="https://webpack.js.org/concepts/#loaders" rel="noopener noreferrer"&gt;&lt;strong&gt;Webpack&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;,&lt;/strong&gt; &lt;a href="https://esbuild.github.io/content-types/" rel="noopener noreferrer"&gt;&lt;strong&gt;Esbuild&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;, etc.&lt;/strong&gt;)&lt;/p&gt;

&lt;p&gt;Without this, you’d need to manually process these files before bundling them.&lt;/p&gt;




&lt;h2&gt;
  
  
  Do I need to know how to configure a module bundler?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;👉 No.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Unless you’re &lt;em&gt;very&lt;/em&gt; unlucky, you shouldn’t have to.&lt;/p&gt;

&lt;p&gt;For this post, I asked &lt;a href="https://v0.dev" rel="noopener noreferrer"&gt;v0.dev&lt;/a&gt; to generate the esbuild setup for me 😅.&lt;/p&gt;

&lt;p&gt;In my professional life, I’ve never had to configure bundlers myself—our great &lt;strong&gt;infra team&lt;/strong&gt; handles it.&lt;/p&gt;

&lt;p&gt;If you don’t have an infra team, here are your options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use tools (like &lt;strong&gt;Vite)&lt;/strong&gt; that configure bundlers for you.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Google how to do it (plenty of examples out there).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ask AI (which is what I did).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;What &lt;em&gt;matters&lt;/em&gt; is understanding &lt;em&gt;what&lt;/em&gt; bundlers do so you don’t get in their way.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Module bundlers (esbuild, Rollup, Webpack, etc.) &lt;strong&gt;are not hard to understand&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;They take &lt;strong&gt;many files&lt;/strong&gt; and output &lt;strong&gt;fewer files&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;They’re useful because they:&lt;/p&gt;

&lt;p&gt;✅ Ensure dependencies load in the correct order.&lt;br&gt;&lt;br&gt;
✅ Reduce the number of HTTP requests needed.&lt;br&gt;&lt;br&gt;
✅ Optimize file sizes for faster downloads.&lt;br&gt;&lt;br&gt;
✅ Enable &lt;strong&gt;code-splitting&lt;/strong&gt; for better performance.&lt;br&gt;&lt;br&gt;
✅ (Bonus) Support non-JS files like &lt;code&gt;.ts&lt;/code&gt; and &lt;code&gt;.json&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So, pick a bundler, play with it, and see it in action.&lt;/p&gt;

&lt;p&gt;In my next post, I’ll share &lt;strong&gt;tips to optimize bundle size.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider" width="800" height="41"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;That's a wrap 🎉.&lt;/p&gt;

&lt;p&gt;Leave a comment 📩 to keep the discussion going.&lt;/p&gt;

&lt;p&gt;And don't forget to drop a "💖🦄🔥".&lt;/p&gt;

&lt;p&gt;If you're learning React, download my &lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" rel="noopener noreferrer"&gt;101 React Tips &amp;amp; Tricks book&lt;/a&gt; for &lt;strong&gt;FREE&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you like articles like this, join my &lt;strong&gt;FREE&lt;/strong&gt; newsletter, &lt;strong&gt;&lt;a href="https://frontendjoy.com/" rel="noopener noreferrer"&gt;FrontendJoy&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you want daily tips, find me on &lt;a href="https://twitter.com/_ndeyefatoudiop" rel="noopener noreferrer"&gt;X/Twitter&lt;/a&gt; or &lt;a href="https://bsky.app/profile/ndeyefatoudiop.bsky.social" rel="noopener noreferrer"&gt;Bluesky&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  🍔 FOOD FOR THOUGHT
&lt;/h2&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1875150173443362895-292" src="https://platform.twitter.com/embed/Tweet.html?id=1875150173443362895"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1875150173443362895-292');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1875150173443362895&amp;amp;theme=dark"
  }



&lt;/p&gt;

</description>
      <category>frontend</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>bundler</category>
    </item>
    <item>
      <title>✨ How to Be More Confident as a Junior Dev—Even When You’re Overwhelmed</title>
      <dc:creator>Ndeye Fatou Diop</dc:creator>
      <pubDate>Thu, 23 Jan 2025 08:48:18 +0000</pubDate>
      <link>https://dev.to/_ndeyefatoudiop/how-to-be-more-confident-as-a-junior-dev-even-when-youre-overwhelmed-235e</link>
      <guid>https://dev.to/_ndeyefatoudiop/how-to-be-more-confident-as-a-junior-dev-even-when-youre-overwhelmed-235e</guid>
      <description>&lt;p&gt;Do you constantly look under-confident at your job and need to be pumped?&lt;/p&gt;

&lt;p&gt;If yes, &lt;strong&gt;stop&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It’s OK to feel overwhelmed, but it’s not OK to constantly show it.&lt;/p&gt;

&lt;p&gt;In this article, I will explain why it’s important to display confidence and how to achieve it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" class="ltag_cta ltag_cta--branded" rel="noopener noreferrer"&gt;📚 Download my FREE 101 React Tips And Tricks Book for a head start.&lt;/a&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Why it is important to display confidence
&lt;/h2&gt;

&lt;p&gt;Have you noticed how we are all attracted to confident leaders?&lt;/p&gt;

&lt;p&gt;Because they are reassuring and look like they know where they are going.&lt;/p&gt;

&lt;p&gt;Well, turns out &lt;strong&gt;confidence is not just a good thing for leaders&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It will also tremendously help you as a junior frontend dev.&lt;/p&gt;

&lt;p&gt;Here are &lt;strong&gt;3&lt;/strong&gt; reasons why:&lt;/p&gt;




&lt;h3&gt;
  
  
  Reason #1: The more confidence you display, the easier it is to trust you
&lt;/h3&gt;

&lt;p&gt;Imagine you are sick 🥴.&lt;/p&gt;

&lt;p&gt;You go to the hospital and have the option between two doctors for your treatment.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The first doctor talks confidently, speaks assertively and can reassure you while being honest.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The second doctor talks tentatively, hesitates a lot, and doesn’t give you a clear answer.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Which doctor are you more likely to choose?&lt;/p&gt;

&lt;p&gt;If you’re like me and most people, you would choose the first doctor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Because if someone doesn’t trust themselves, why should you trust them?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This also applies to you as a junior frontend dev.&lt;/p&gt;

&lt;p&gt;If you don’t trust yourself and make this evident to everyone, it will be harder for others to trust you.&lt;/p&gt;




&lt;h3&gt;
  
  
  Reason #2: The more confidence you display, the more ownership you can get
&lt;/h3&gt;

&lt;p&gt;Since you get more trust, you’ll also have more opportunities than a less confident dev.&lt;/p&gt;

&lt;p&gt;And when you can turn these opportunities around, you get even more ownership.&lt;/p&gt;




&lt;h3&gt;
  
  
  Reason #3: The more confidence you display, the less effort it takes to reassure you
&lt;/h3&gt;

&lt;p&gt;Unfortunately, people will generally try to comfort you when you show under-confidence.&lt;/p&gt;

&lt;p&gt;This is OK in small doses.&lt;/p&gt;

&lt;p&gt;However, if you consistently need reassurance, it could be tiring in the long term.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Time that could have been spent mentoring you is now spent comforting you.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is rarely sustainable.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl3pwln9p9uz5q06lcbyv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl3pwln9p9uz5q06lcbyv.png" alt="FrontendJoy NewsLetter Divider" width="800" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Build (and Show) Your Confidence
&lt;/h2&gt;

&lt;p&gt;Displaying confidence is hard.&lt;/p&gt;

&lt;p&gt;I know because I still have to force myself to do it after 5+ years of experience 😅.&lt;/p&gt;

&lt;p&gt;However, you can use these &lt;strong&gt;5 hacks&lt;/strong&gt; to feel and look more confident.&lt;/p&gt;




&lt;h3&gt;
  
  
  Hack #1: Don’t bite more than you can chew
&lt;/h3&gt;

&lt;p&gt;This hack is obvious.&lt;/p&gt;

&lt;p&gt;However, it is easy to fall into this trap 🪤.&lt;/p&gt;

&lt;p&gt;We generally fall into it because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;We volunteer for too many projects to show willingness&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We volunteer for projects without knowing the scale or discussing with a more senior dev first&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We suffer from people-pleasing and can’t say &lt;em&gt;“No”&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Unfortunately, &lt;strong&gt;when you bite more than you can chew, your confidence will take a toll&lt;/strong&gt; since you are more likely to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;underperform on tasks and lose some of your confidence&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;overwork, which leads to tiredness and feeling overwhelmed&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What to do instead:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Have a clear idea of your workload and make it clear to your manager&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Only volunteer for projects you have 100% confidence in at the beginning, then be more audacious over time&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Re-evaluate your workload with your manager regularly (and drop some tasks if needed)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Hack #2: Give yourself permission to ask for help
&lt;/h3&gt;

&lt;p&gt;Whenever I felt under-confident, I wanted to do everything alone and didn’t want to ask for help.&lt;/p&gt;

&lt;p&gt;As a result, I would get stuck and not ask for help 🤪.&lt;/p&gt;

&lt;p&gt;This would undermine my confidence since I was expecting to do something, then realized I couldn’t.&lt;/p&gt;

&lt;p&gt;A good remedy is to &lt;strong&gt;ask for help when you’re stuck after some time&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This is great because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It stops the stress buildup since you’re forced to stop and interact with others&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It helps you brainstorm with other people and feel less alone&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It often enables you to realize the task was more challenging than you expected&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Hack #3: Take regular breaks
&lt;/h3&gt;

&lt;p&gt;After working long hours, your productivity drops, and further work can become counterproductive.&lt;/p&gt;

&lt;p&gt;Your brain is tired, and you make more mistakes than actual progress.&lt;/p&gt;

&lt;p&gt;Unfortunately, this can break your confidence since you keep spending time on the problem without progress.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The solution is simple: take regular breaks&lt;/strong&gt;. At least one break every 90 minutes.&lt;/p&gt;

&lt;p&gt;Unfortunately, this can be hard to do (at least for me 😅).&lt;/p&gt;

&lt;p&gt;What helps is to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Schedule catchups/meetings that force you to stop&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Interact with your colleagues&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Do something not related to coding, like code reviews&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Hack #4: Track your achievements regularly
&lt;/h3&gt;

&lt;p&gt;You may not realize it, but you’ve already achieved much as a junior frontend dev 👏.&lt;/p&gt;

&lt;p&gt;Unfortunately, it’s easy to focus on what you don’t know instead of what you’ve learned.&lt;/p&gt;

&lt;p&gt;This can undermine your confidence since you feel like you don’t know enough.&lt;/p&gt;

&lt;p&gt;I have some good news: &lt;em&gt;“None of us know enough. What we don’t know is way more than what we know.”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So don’t let this hold you back.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Have a place to track your achievements to see how far you’ve already come.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This will boost your confidence 💪.&lt;/p&gt;




&lt;h3&gt;
  
  
  Hack #5: Share experiences with your peers or discuss your journey with others
&lt;/h3&gt;

&lt;p&gt;As soon as you talk with other junior devs or senior devs about their early experiences, you’ll realize that feeling overwhelmed is normal.&lt;/p&gt;

&lt;p&gt;In fact, the tech space is fast-changing, complex, and varied.&lt;/p&gt;

&lt;p&gt;It’s normal to feel overwhelmed initially, especially when navigating old code or completing your first tasks.&lt;/p&gt;

&lt;p&gt;Instead of panicking, embrace the process 😌.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Expect discomfort to be part of the job.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Stay calm and learn.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl3pwln9p9uz5q06lcbyv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl3pwln9p9uz5q06lcbyv.png" alt="FrontendJoy NewsLetter Divider" width="800" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Feeling overwhelmed as a junior frontend developer is normal.&lt;/p&gt;

&lt;p&gt;However, just because you feel overwhelmed doesn’t mean you have to show it.&lt;/p&gt;

&lt;p&gt;Instead, strive to display confidence so you get more opportunities and trust.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ensure you don’t bite more than you can chew, build a support system, and interact with your peers.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I trust you’ll be successful 🚀.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl3pwln9p9uz5q06lcbyv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl3pwln9p9uz5q06lcbyv.png" alt="FrontendJoy NewsLetter Divider" width="800" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it.&lt;/p&gt;

&lt;p&gt;Don't forget to drop a "💖🦄🔥".&lt;/p&gt;

&lt;p&gt;If you're learning React, download my &lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" rel="noopener noreferrer"&gt;101 React Tips &amp;amp; Tricks book&lt;/a&gt; for &lt;strong&gt;FREE&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you like articles like this, join my &lt;strong&gt;FREE&lt;/strong&gt; newsletter, &lt;strong&gt;&lt;a href="https://frontendjoy.com/" rel="noopener noreferrer"&gt;FrontendJoy&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you want daily tips, find me on &lt;a href="https://twitter.com/_ndeyefatoudiop" rel="noopener noreferrer"&gt;X/Twitter&lt;/a&gt; or &lt;a href="https://bsky.app/profile/ndeyefatoudiop.bsky.social" rel="noopener noreferrer"&gt;Bluesky&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl3pwln9p9uz5q06lcbyv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl3pwln9p9uz5q06lcbyv.png" alt="FrontendJoy NewsLetter Divider" width="800" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🐞 SPOT THE BUG
&lt;/h2&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1879498832100442408-554" src="https://platform.twitter.com/embed/Tweet.html?id=1879498832100442408"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1879498832100442408-554');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1879498832100442408&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;h2&gt;
  
  
  🍔 FOOD FOR THOUGHT
&lt;/h2&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1879438387150811498-216" src="https://platform.twitter.com/embed/Tweet.html?id=1879438387150811498"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1879438387150811498-216');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1879438387150811498&amp;amp;theme=dark"
  }



&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>career</category>
      <category>javascript</category>
    </item>
    <item>
      <title>7 Critical Pitfalls New Developers Must Avoid in Their First Weeks</title>
      <dc:creator>Ndeye Fatou Diop</dc:creator>
      <pubDate>Tue, 14 Jan 2025 13:00:00 +0000</pubDate>
      <link>https://dev.to/_ndeyefatoudiop/7-critical-pitfalls-new-developers-must-avoid-in-their-first-weeks-2l21</link>
      <guid>https://dev.to/_ndeyefatoudiop/7-critical-pitfalls-new-developers-must-avoid-in-their-first-weeks-2l21</guid>
      <description>&lt;p&gt;For the past 6+ years, I’ve worked across 5+ teams at Palantir.&lt;/p&gt;

&lt;p&gt;I wish someone had warned me about these 7 mistakes at the start of my career.&lt;/p&gt;

&lt;p&gt;Ready? Let’s get started.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" class="ltag_cta ltag_cta--branded" rel="noopener noreferrer"&gt;📚 Download my FREE 101 React Tips And Tricks Book for a head start.&lt;/a&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Mistake #1: Giving strong opinions about things you don’t fully understand yet
&lt;/h2&gt;

&lt;p&gt;We want to prove our value during the first days of a job.&lt;/p&gt;

&lt;p&gt;It’s &lt;strong&gt;natural&lt;/strong&gt; to want to show your colleagues that you were worth hiring 😀.&lt;/p&gt;

&lt;p&gt;However, this can lead to giving strong opinions on things you don’t fully understand yet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Someone asks about testing → you proclaim, &lt;em&gt;“It’s criminal not to have 100% coverage.”&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Someone talks about state management libraries → you question why the team uses Redux and suggest Zustand.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The team decides to cut features to meet a deadline → you talk about how this would’ve backfired at your previous company, lost users, yada yada...&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;I can tell you right now: this will not land well 99% of the time.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You don’t have the full context, so your input is, at best, noisy and, at worst, counterproductive.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You waste your colleagues’ time as they argue or explain things to you.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You may come across as “show-offy” without realizing it. This isn’t the best way to make friends 😅.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, should you keep quiet during your first weeks? &lt;strong&gt;Absolutely not.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You were hired to contribute to the team and share your perspective. However, make sure that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You collect as much context about the team and product as possible—ask “why” first.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You don’t get too attached to your opinions. Present them as suggestions rather than hard truths.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You “show, don’t tell” whenever possible.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16aite135qk16sgisyjm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16aite135qk16sgisyjm.png" alt="Section Divider" width="800" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Mistake #2: Trying to figure out everything by yourself
&lt;/h2&gt;

&lt;p&gt;Unless you’re the only person on your team, ask for help.&lt;/p&gt;

&lt;p&gt;Ask after trying for a reasonable amount of time. What’s reasonable depends on the type of question:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If you’re sure you won’t find a solution even after an hour—or if the issue blocks your productivity—ask immediately. For example, you should ask questions like &lt;em&gt;“How do I set up this computer to work with tests?”&lt;/em&gt; instantly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If it’s a technical problem you can solve by Googling or using AI tools, try that first. If it doesn’t work, ask for help after 30 minutes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why ask for help?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You don’t know what you don’t know.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Time spent figuring out what others already know is time you could spend on productive work.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;If you’re in an environment where help isn’t readily available, you’ll have to figure things out.&lt;/p&gt;

&lt;p&gt;Make sure to document your findings for the next person. This builds a knowledge base and earns you “good teammate” points.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16aite135qk16sgisyjm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16aite135qk16sgisyjm.png" alt="Section Divider" width="800" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Mistake #3: Focusing too much on onboarding and ignoring your colleagues’ work
&lt;/h2&gt;

&lt;p&gt;I’m super introverted 🙈.&lt;/p&gt;

&lt;p&gt;So, I find it hard to reach out randomly to new people.&lt;/p&gt;

&lt;p&gt;However, whenever I’ve joined new teams, I’ve forced myself to talk to teammates—and it’s always paid off.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Onboarding felt less intimidating when I realized my colleagues were normal people willing to help.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I gained valuable context and understood what mattered most to the team.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I built a network of people I could turn to for support.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, as soon as you join a new team, set up &lt;strong&gt;1-on-1 meetings&lt;/strong&gt; with teammates.&lt;/p&gt;

&lt;p&gt;Ask them about their work, the team’s history, how they see their role, and any advice they might have.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16aite135qk16sgisyjm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16aite135qk16sgisyjm.png" alt="Section Divider" width="800" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Mistake #4: Trying to memorize everything
&lt;/h2&gt;

&lt;p&gt;On my first team, I felt super lost 😅.&lt;/p&gt;

&lt;p&gt;People used acronyms in meetings, and I struggled to follow conversations. Even when I knew some of the acronyms, I still felt overwhelmed.&lt;/p&gt;

&lt;p&gt;I tried to memorize everything.&lt;/p&gt;

&lt;p&gt;But this was pointless.&lt;/p&gt;

&lt;p&gt;Everything will eventually become second nature. It’s normal to feel overwhelmed at first.&lt;/p&gt;

&lt;p&gt;The key is to keep asking clarifying questions.&lt;/p&gt;

&lt;p&gt;Over time, you’ll understand things better and build muscle memory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16aite135qk16sgisyjm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16aite135qk16sgisyjm.png" alt="Section Divider" width="800" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Mistake #5: Complaining excessively about your team systems
&lt;/h2&gt;

&lt;p&gt;No codebase is perfect.&lt;/p&gt;

&lt;p&gt;No team is perfect.&lt;/p&gt;

&lt;p&gt;Books and blogs often give the impression that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Everyone should use the latest libraries or frameworks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;All legacy code should be refactored.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you land on a team with different practices or “messy” code, you might start complaining.&lt;/p&gt;

&lt;p&gt;You might even make a list of everything that’s “wrong.” 🤦‍♀️&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This is the worst way to start a new job.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Unless you were hired to overhaul the team and its processes (and even then), don’t do this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You’re implying that the team is “poor” for missing things.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You’re adding unsolicited work for your colleagues.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You’re alienating people who built the systems without understanding the constraints they faced.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead, have a positive attitude:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Look for ways to provide value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Show, don’t tell: introduce better patterns in your pull requests.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open technical discussions with the team.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you’re unhappy with the systems, consider interviewing elsewhere 😌.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16aite135qk16sgisyjm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16aite135qk16sgisyjm.png" alt="Section Divider" width="800" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Mistake #6: Attempting to refactor code without context
&lt;/h2&gt;

&lt;p&gt;I’ve made this mistake.&lt;/p&gt;

&lt;p&gt;I wanted to provide value, so I refactored code without being asked.&lt;/p&gt;

&lt;p&gt;It didn’t go as well as I hoped.&lt;/p&gt;

&lt;p&gt;Later, when someone joined the team and refactored my code without asking, I got a taste of my own medicine 😅.&lt;/p&gt;

&lt;p&gt;Refactoring someone’s code without context can feel like an attack. It’s like someone spoiling your art.&lt;/p&gt;

&lt;p&gt;Don’t @ me: I know this is not healthy😅.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it’s a problem:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You miss the context for why the code exists.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You overlook more essential tasks.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead, only refactor code if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Someone asks for help.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can integrate the refactor into meaningful work (e.g., a pull request).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16aite135qk16sgisyjm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16aite135qk16sgisyjm.png" alt="Section Divider" width="800" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Mistake #7: Setting unrealistic expectations
&lt;/h2&gt;

&lt;p&gt;Don’t work 12–14 hours a day during your first weeks unless you plan to do so long-term.&lt;/p&gt;

&lt;p&gt;It might seem like a good idea because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You want to prove your value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You feel there’s too much to learn.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You’re on probation.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But this can backfire:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It sets unrealistic expectations for your team. Scaling back later could create friction.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It’s unsustainable and might lead to burnout.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Meet the team’s expectations first.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you want to do more, ensure it’s sustainable and beneficial.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first weeks are a grace period. People expect you to learn, not to immediately deliver value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16aite135qk16sgisyjm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16aite135qk16sgisyjm.png" alt="Section Divider" width="800" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's a wrap 🎉.&lt;/p&gt;

&lt;p&gt;Onboarding is challenging.&lt;/p&gt;

&lt;p&gt;But some mistakes can make it far worse:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Sharing strong opinions without context.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Taking actions without context.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Not leveraging your colleagues.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Avoid these mistakes, and you’ll settle into your new team quickly.&lt;/p&gt;

&lt;p&gt;And don't forget to drop a "💖🦄🔥".&lt;/p&gt;

&lt;p&gt;If you're learning React, download my &lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" rel="noopener noreferrer"&gt;101 React Tips &amp;amp; Tricks book&lt;/a&gt; for &lt;strong&gt;FREE&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you like articles like this, join my &lt;strong&gt;FREE&lt;/strong&gt; newsletter, &lt;strong&gt;&lt;a href="https://frontendjoy.com/" rel="noopener noreferrer"&gt;FrontendJoy&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you want daily tips, find me on &lt;a href="https://twitter.com/_ndeyefatoudiop" rel="noopener noreferrer"&gt;X/Twitter&lt;/a&gt; or &lt;a href="https://bsky.app/profile/ndeyefatoudiop.bsky.social" rel="noopener noreferrer"&gt;Bluesky&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16aite135qk16sgisyjm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16aite135qk16sgisyjm.png" alt="Section Divider" width="800" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  💡 TIP OF THE WEEK
&lt;/h2&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1877747297402142883-419" src="https://platform.twitter.com/embed/Tweet.html?id=1877747297402142883"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1877747297402142883-419');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1877747297402142883&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16aite135qk16sgisyjm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16aite135qk16sgisyjm.png" alt="Section Divider" width="800" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🍔 FOOD FOR THOUGHT
&lt;/h2&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1876901704563872142-960" src="https://platform.twitter.com/embed/Tweet.html?id=1876901704563872142"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1876901704563872142-960');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1876901704563872142&amp;amp;theme=dark"
  }



&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>career</category>
    </item>
    <item>
      <title>17 Tips from a Senior React Developer</title>
      <dc:creator>Ndeye Fatou Diop</dc:creator>
      <pubDate>Tue, 07 Jan 2025 11:00:00 +0000</pubDate>
      <link>https://dev.to/_ndeyefatoudiop/17-tips-from-a-senior-react-developer-2249</link>
      <guid>https://dev.to/_ndeyefatoudiop/17-tips-from-a-senior-react-developer-2249</guid>
      <description>&lt;p&gt;I've been writing React code as an engineer at Palantir for the past 5+ years.&lt;/p&gt;

&lt;p&gt;These are the 17 tips I wish someone had shared with me when I was starting.&lt;/p&gt;

&lt;p&gt;Ready? Let's dive in! 💪&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" class="ltag_cta ltag_cta--branded" rel="noopener noreferrer"&gt;📚 Download my FREE 101 React Tips And Tricks Book for a head start.&lt;/a&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Learn JavaScript before React
&lt;/h2&gt;

&lt;p&gt;When I first started, I jumped from writing functions and basic DOM manipulation to learning React.&lt;/p&gt;

&lt;p&gt;As you can guess, it didn't go well 🤯.&lt;/p&gt;

&lt;p&gt;This is a common mistake for junior developers: trying to learn React without a solid understanding of JavaScript.&lt;/p&gt;

&lt;p&gt;It's a recipe for confusion:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You won't know what is React-specific and what is just JavaScript.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Debugging becomes a nightmare.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What to do instead?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Learn enough JavaScript to get comfortable (check out &lt;a href="https://kentcdodds.com/blog/javascript-to-know-for-react" rel="noopener noreferrer"&gt;JavaScript to Know for React)&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then, dive into React.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider" width="800" height="41"&gt;&lt;/a&gt;   &lt;/p&gt;

&lt;h2&gt;
  
  
  2. Read the React docs
&lt;/h2&gt;

&lt;p&gt;You don't need money 💰, a coach, or a fancy course to learn React.&lt;/p&gt;

&lt;p&gt;Head to the &lt;a href="https://react.dev" rel="noopener noreferrer"&gt;official React website&lt;/a&gt; and:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Follow the Quick Start &lt;a href="https://react.dev/learn" rel="noopener noreferrer"&gt;guide&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Read the &lt;a href="https://react.dev/learn/describing-the-ui" rel="noopener noreferrer"&gt;learning&lt;/a&gt; chapters (even if they don't make sense initially, they'll click later).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider" width="800" height="41"&gt;&lt;/a&gt;   &lt;/p&gt;

&lt;h2&gt;
  
  
  3. Start building projects early
&lt;/h2&gt;

&lt;p&gt;Watching tutorials won't make you a React developer.&lt;/p&gt;

&lt;p&gt;Spending $100, $200, or even $700 on courses won't either.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What will?&lt;/strong&gt; Building projects.&lt;/p&gt;

&lt;p&gt;It's the best way to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Learn by making mistakes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Discover gaps in your knowledge.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pick up new patterns and tips.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Stuck for ideas? Try these resources 👇:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.frontendmentor.io/" rel="noopener noreferrer"&gt;&lt;strong&gt;Frontend Mentor&lt;/strong&gt;&lt;/a&gt;: Projects for all skill levels.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://frontendpractice.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;Frontend Practice&lt;/strong&gt;&lt;/a&gt;: Recreate real websites.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.frontendprojects.io/" rel="noopener noreferrer"&gt;&lt;strong&gt;Frontend Projects&lt;/strong&gt;&lt;/a&gt;: Varied project ideas.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.youtube.com/c/javascriptmastery" rel="noopener noreferrer"&gt;&lt;strong&gt;JavaScript Mastery&lt;/strong&gt;&lt;/a&gt;: A YouTube channel with project-based tutorials.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider" width="800" height="41"&gt;&lt;/a&gt;    &lt;/p&gt;

&lt;h2&gt;
  
  
  4. Use trusted libraries
&lt;/h2&gt;

&lt;p&gt;Not all packages are safe.&lt;/p&gt;

&lt;p&gt;For example, in 2021, a popular NPM package, &lt;a href="https://www.npmjs.com/package/ua-parser-js" rel="noopener noreferrer"&gt;ua-parser-js&lt;/a&gt;, was hacked, spreading malware 📛.&lt;/p&gt;

&lt;p&gt;To minimize risks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use libraries from trusted authors.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check for good download volumes and regular updates.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider" width="800" height="41"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  5. Solve problems with Vanilla JS when possible
&lt;/h2&gt;

&lt;p&gt;Previously, you needed libraries like &lt;a href="https://lodash.com/" rel="noopener noreferrer"&gt;lodash&lt;/a&gt; for tasks like cloning, iteration, etc.&lt;/p&gt;

&lt;p&gt;But modern JavaScript has improved a lot.&lt;/p&gt;

&lt;p&gt;Now, you can achieve a lot with native methods.&lt;/p&gt;

&lt;p&gt;So, don’t add a library if you don't have to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every library you add:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Increases your app's dependencies, making it more vulnerable to security issues.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Potentially adds to your bundle size, slowing down load times.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Increases your app’s build/compilation time&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Creates maintenance overhead to keep dependencies updated.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before reaching for a library, check if Vanilla JS can do the job. It often can 😉.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider" width="800" height="41"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  6. Optimize bundle size and lazy load as much as possible
&lt;/h2&gt;

&lt;p&gt;It starts slow.&lt;/p&gt;

&lt;p&gt;You add one package here.&lt;/p&gt;

&lt;p&gt;Then another there.&lt;/p&gt;

&lt;p&gt;And then another.&lt;/p&gt;

&lt;p&gt;Before you know it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Users complain the app takes too long to load.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Developers complain the build process is painfully slow.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why does this happen?&lt;/p&gt;

&lt;p&gt;Packages and heavy components were added without considering their impact on bundle size 🤦‍♀️.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to fix it?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Lazy-load&lt;/strong&gt; as much as possible.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set up checks to track bundle size increases (Pull Request actions work well for this).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use &lt;a href="https://bundlephobia.com/" rel="noopener noreferrer"&gt;bundlephobia&lt;/a&gt; to check package size before adding it to your project.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider" width="800" height="41"&gt;&lt;/a&gt;   &lt;/p&gt;

&lt;h2&gt;
  
  
  7. Colocate related logic
&lt;/h2&gt;

&lt;p&gt;Grouping files by type (e.g., components, utils, i18n) might seem like a good idea, but it's not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It's harder to follow a component's logic when files are scattered.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You risk cleaning a component but forgetting related files.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead, keep all a component's logic and assets together in one folder.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider" width="800" height="41"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  8. Keep components simple
&lt;/h2&gt;

&lt;p&gt;Avoid "God" components—those that try to do everything.&lt;/p&gt;

&lt;p&gt;They're problematic ❌ because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;They're harder to read and understand.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;They often lead to version control conflicts (Git, GitLab, etc.).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Modifying them can unintentionally impact the entire app.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What to do instead?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Think about how you'd structure your code if you were working with a teammate.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keep your components focused on one task to minimize conflicts.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This approach keeps your code clean and helps your team work more efficiently.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider" width="800" height="41"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  9. Solve diverse problems
&lt;/h2&gt;

&lt;p&gt;The more problems you solve with React, the better you get 🚀.&lt;/p&gt;

&lt;p&gt;Every challenge you tackle teaches you something valuable:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You uncover new patterns and anti-patterns.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You add more tools to your developer toolbox.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You gain confidence in your skills.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But here's the key: don't just practice—&lt;strong&gt;vary&lt;/strong&gt; your practice.&lt;/p&gt;

&lt;p&gt;Explore different kinds of problems, projects, and solutions. That variety will help you grow faster as a React developer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider" width="800" height="41"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  10. Learn good programming patterns
&lt;/h2&gt;

&lt;p&gt;As a React dev, you should also focus on foundational programming skills:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Data Structures &amp;amp; Algorithms (e.g., sets, maps, recursion).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Principles like those in &lt;a href="https://pragprog.com/titles/tpp20/the-pragmatic-programmer-20th-anniversary-edition/" rel="noopener noreferrer"&gt;The Pragmatic Programmer.&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider" width="800" height="41"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  11. Read a ton of React code
&lt;/h2&gt;

&lt;p&gt;Building projects isn't the only way to learn—reading code is just as valuable 💪.&lt;/p&gt;

&lt;p&gt;It helps you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Pick up new tips and tricks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Compare approaches to solving problems.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, check out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Open-source projects on GitHub.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Your teammates' code at work.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider" width="800" height="41"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  12. Use TypeScript ASAP
&lt;/h2&gt;

&lt;p&gt;There's a &lt;em&gt;before&lt;/em&gt; and an &lt;em&gt;after&lt;/em&gt; TypeScript 😅.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Before:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You spend extra time double-checking that you've passed the correct props.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Debugging can take hours, only to realize you passed the wrong value—or worse, &lt;code&gt;undefined&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;After:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You focus on structuring your components and defining types.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You catch silly mistakes before they reach production.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;TypeScript isn't just a tool—it's a game changer for your React workflow.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider" width="800" height="41"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  13. Avoid early abstractions
&lt;/h2&gt;

&lt;p&gt;I used to be guilty of this a lot 🙈.&lt;/p&gt;

&lt;p&gt;Whenever I designed a simple component, I'd try to make it reusable and future-proof.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The problem?&lt;/strong&gt; I often created the wrong abstraction because there were no immediate needs.&lt;/p&gt;

&lt;p&gt;This led to two outcomes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;I'd end up refactoring the code later.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Or worse, I'd have to live with the awkward abstraction, making development harder.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;What to do instead?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Write a component that solves the problem at hand.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Extend it &lt;em&gt;only if&lt;/em&gt; there's a clear need for reuse, and do so gradually. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a deeper dive into this topic, check out this great &lt;a href="https://www.youtube.com/watch?v=17KCHwOwgms" rel="noopener noreferrer"&gt;video by Dan Abramov&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider" width="800" height="41"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  14. Use React's built-in state management first
&lt;/h2&gt;

&lt;p&gt;You don't need &lt;a href="https://redux.js.org/" rel="noopener noreferrer"&gt;Redux&lt;/a&gt; or &lt;a href="https://jotai.org/" rel="noopener noreferrer"&gt;Jotai&lt;/a&gt; right away.&lt;/p&gt;

&lt;p&gt;React's useState, useReducer, and useContext go a long way for simple apps.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider" width="800" height="41"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  15. Don't mindlessly follow online advice
&lt;/h2&gt;

&lt;p&gt;A few years ago, I read online that memoization was "evil."&lt;/p&gt;

&lt;p&gt;So, I stopped using it in my React apps.&lt;/p&gt;

&lt;p&gt;That was until I crashed an app in production. 😅&lt;/p&gt;

&lt;p&gt;The advice made sense for the developer who shared it, but it backfired for me because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I had different use cases.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I needed to use effects in my app.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I was working with large-scale components.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Main takeaway?&lt;/strong&gt; Don't mindlessly follow the advice you find online. Instead:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Discuss it with your teammates (if you have them).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Evaluate whether it applies to your specific context.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Note: With React 19 optimization, this advice may finally be accurate&lt;/em&gt; 😅&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider" width="800" height="41"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  16. Make time for refactoring
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;“When developers are too afraid to clean bad code when they see it; then the system will start to rot. As the rot increases, so does the fear -- so the rot accelerates. At some point the code is such a horrible mess than none of the developers can estimate the effect of a particular change. Adding an icon might break other unrelated things.”&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Uncle Bob Martin&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every now and then, you'll notice that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Your React components no longer make sense.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;They've grown complex or too large.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There's room for improvement.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When this happens, take 5–30 minutes to refactor.&lt;/p&gt;

&lt;p&gt;Small, regular enhancements can make your components easier to manage and prevent headaches.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider" width="800" height="41"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  17. Only use frameworks when necessary
&lt;/h2&gt;

&lt;p&gt;Spoiler: You don't need a framework to use React.&lt;/p&gt;

&lt;p&gt;A simple React, &lt;a href="https://vite.dev/" rel="noopener noreferrer"&gt;Vite&lt;/a&gt;, and &lt;a href="https://reactrouter.com/" rel="noopener noreferrer"&gt;react-router&lt;/a&gt; setup can go a long way.&lt;/p&gt;

&lt;p&gt;Use frameworks like &lt;a href="https://nextjs.org/" rel="noopener noreferrer"&gt;Next.js&lt;/a&gt; or &lt;a href="https://remix.run/" rel="noopener noreferrer"&gt;Remix&lt;/a&gt; only when your app requires their features.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisqsfnjxnhz9zz6gveau.png" alt="Section Divider" width="800" height="41"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;That's a wrap 🎉.&lt;/p&gt;

&lt;p&gt;Leave a comment 📩 to share your best tip.&lt;/p&gt;

&lt;p&gt;And don't forget to drop a "💖🦄🔥".&lt;/p&gt;

&lt;p&gt;If you're learning React, download my &lt;a href="https://www.frontendjoy.com/p/download-my-free-101-react-tips-tricks-book" rel="noopener noreferrer"&gt;101 React Tips &amp;amp; Tricks book&lt;/a&gt; for &lt;strong&gt;FREE&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you like articles like this, join my &lt;strong&gt;FREE&lt;/strong&gt; newsletter, &lt;strong&gt;&lt;a href="https://frontendjoy.com/" rel="noopener noreferrer"&gt;FrontendJoy&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you want daily tips, find me on &lt;a href="https://twitter.com/_ndeyefatoudiop" rel="noopener noreferrer"&gt;X/Twitter&lt;/a&gt; or &lt;a href="https://bsky.app/profile/ndeyefatoudiop.bsky.social" rel="noopener noreferrer"&gt;Bluesky&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  🐞 SPOT THE BUG
&lt;/h2&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1875150173443362895-61" src="https://platform.twitter.com/embed/Tweet.html?id=1875150173443362895"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1875150173443362895-61');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1875150173443362895&amp;amp;theme=dark"
  }



&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>career</category>
    </item>
  </channel>
</rss>
