<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by saijami on Medium]]></title>
        <description><![CDATA[Stories by saijami on Medium]]></description>
        <link>https://medium.com/@saijamii?source=rss-4d3792bfce44------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*NkbuKOcodd7feZQtiw4SGw.png</url>
            <title>Stories by saijami on Medium</title>
            <link>https://medium.com/@saijamii?source=rss-4d3792bfce44------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 03:33:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@saijamii/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Tree Shaking in React: Trim Dead Code for Blazing Performance]]></title>
            <link>https://saijamii.medium.com/tree-shaking-in-react-trim-dead-code-for-blazing-performance-1f2b89246c16?source=rss-4d3792bfce44------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f2b89246c16</guid>
            <category><![CDATA[performance-optimization]]></category>
            <category><![CDATA[react-performance]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[tree-shaking]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[saijami]]></dc:creator>
            <pubDate>Fri, 13 Jun 2025 15:32:08 GMT</pubDate>
            <atom:updated>2025-06-13T15:32:08.477Z</atom:updated>
            <content:encoded><![CDATA[<p>Still importing more than you need?<br>Tree shaking helps you <strong>ship less JavaScript</strong>, load faster, and optimize your React apps with zero runtime cost.</p><h3>🧠 What Is Tree Shaking?</h3><p>Tree shaking is the process of <strong>removing unused code</strong> from your JavaScript bundle. It’s based on analyzing <strong>static ES module imports</strong> (import { x } from &#39;y&#39;) and pruning any exports that your app doesn’t use — like shaking dead leaves off a tree.</p><p>The result? Smaller bundles. Faster loads. Happier users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sFgckUTpf0DIwmgxAaJ6HQ.png" /></figure><p>Tree shaking only works with <strong>ES Modules</strong> (i.e., import/export). It <strong>does not work</strong> with CommonJS (require()), because those imports are dynamic and can’t be statically analyzed.</p><p>💡 Real-World Examples<br>✅ Named Imports: Less is More</p><pre>// Before tree shaking<br>import { usedFunction, unusedFunction } from &#39;my-library&#39;;<br><br>// After tree shaking<br>import { usedFunction } from &#39;my-library&#39;;</pre><h3>🛠 How to Enable Tree Shaking in React</h3><h3>1. Use a Modern Bundler</h3><ul><li>Webpack, Rollup, or Vite — all support tree shaking.</li><li>Create React App uses Webpack with tree shaking <strong>enabled by default</strong> in production.</li></ul><h3>2. Use production Mode</h3><pre>// webpack.config.js<br>module.exports = {<br>  mode: &#39;production&#39;,<br>};</pre><p>This turns on usedExports and triggers dead code elimination.</p><h3>3. Avoid CommonJS</h3><pre>// ❌ Not tree-shakable<br>const lib = require(&#39;library&#39;);<br><br>// ✅ Tree-shakable<br>import { feature } from &#39;library&#39;;</pre><h3>📦 Optimize Further with Babel &amp; Webpack</h3><p>Use @babel/preset-env with modules: false to preserve ESM:</p><pre>{<br>  &quot;presets&quot;: [<br>    [&quot;@babel/preset-env&quot;, { &quot;modules&quot;: false }]<br>  ]<br>}</pre><pre>//package.json<br>{<br> &quot;sideEffects&quot;: false<br>}</pre><h3>📉 Tree Shaking + Bundle Analysis</h3><p>Use tools like:</p><ul><li>🔍 <a href="https://www.npmjs.com/package/webpack-bundle-analyzer">Webpack Bundle Analyzer</a></li><li>🔍 <a href="https://www.npmjs.com/package/source-map-explorer">Source Map Explorer</a></li><li>🔍 Vite’s built-in visualizer</li></ul><p>To find oversized dependencies and unused modules that are bloating your app.</p><h3>🔄 Conclusion: Small Code = Fast Web</h3><p>Tree shaking isn’t magic. It’s <strong>disciplined development</strong>.</p><p>When done right, it:</p><ul><li>Shrinks your JavaScript payload</li><li>Improves first load and Time to Interactive (TTI)</li><li>Makes your apps feel snappier and more professional</li></ul><p>Try running a bundle analysis — you might be shocked at what’s hiding in there.</p><p>// After tree shaking<br>import { usedFunction } from ‘my-library’;</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f2b89246c16" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Art of State Management in React: Avoiding Common Pitfalls]]></title>
            <link>https://saijamii.medium.com/the-art-of-state-management-in-react-avoiding-common-pitfalls-43c1125d4df2?source=rss-4d3792bfce44------2</link>
            <guid isPermaLink="false">https://medium.com/p/43c1125d4df2</guid>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[saijami]]></dc:creator>
            <pubDate>Sun, 08 Jun 2025 16:40:03 GMT</pubDate>
            <atom:updated>2025-06-08T16:40:03.497Z</atom:updated>
            <content:encoded><![CDATA[<p>Not every app needs Redux. Not every bug needs Zustand.<br>Yet so many React developers (me included) jump to global state tools too early — and pay for it with bloated code and hard-to-follow flows.<br>Here’s what I wish I’d known earlier:👇</p><p>The 80/20 Rule of State Management:<br> 🔹 80% of your state should stay local — where it belongs.<br> 🔹 Only 20% truly needs global sync and control.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aXWFqJfpR3FnwoHvVWks2Q.png" /></figure><p>🧠 My personal tool progression (the hard way):<br> ➡️ useState → For simple local state<br> ➡️ useReducer → When logic got messy<br> ➡️ Context → Sharing across 3–5 components<br> ➡️ Zustand/Redux → When true global, persistent state was unavoidable</p><p>Here’s a simple cheat sheet I use now:👇<br>✅ Stick with local state when:<br> • State is used in a single component<br> • Logic is easy to test and reason about<br> • No cross-page sync is needed<br>⚙️ Reach for external tools when:<br> • You’re syncing state across routes or sessions<br> • You need undo/redo, throttling, persistence<br> • You’re hitting performance limits from context nesting or prop drilling<br>Zustand is lean and intuitive.<br> Redux is powerful but comes with overhead.<br> Context is great — until it’s not.<br>The tool isn’t the problem. Knowing when to use it is.<br>💬 What’s your biggest React state management mistake?<br> Let’s make the community smarter, one insight at a time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43c1125d4df2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>