<?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>Forem: Yogesh Bamanier</title>
    <description>The latest articles on Forem by Yogesh Bamanier (@yorgie7).</description>
    <link>https://forem.com/yorgie7</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%2F659961%2Ffd012018-d134-403d-8ea6-570d20d53bd0.jpg</url>
      <title>Forem: Yogesh Bamanier</title>
      <link>https://forem.com/yorgie7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/yorgie7"/>
    <language>en</language>
    <item>
      <title>🚀 React Performance Tip: Why useState(() =&gt; ...) Beats useState({...})</title>
      <dc:creator>Yogesh Bamanier</dc:creator>
      <pubDate>Tue, 25 Nov 2025 18:19:30 +0000</pubDate>
      <link>https://forem.com/yorgie7/react-performance-tip-why-usestate-beats-usestate-5blj</link>
      <guid>https://forem.com/yorgie7/react-performance-tip-why-usestate-beats-usestate-5blj</guid>
      <description>&lt;p&gt;Most developers write:&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="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="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="na"&gt;current&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;initialValue&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;...but don't realize this silently creates &lt;strong&gt;performance overhead&lt;/strong&gt; ---&lt;br&gt;
especially in components that re-render often.&lt;/p&gt;
&lt;h2&gt;
  
  
  Hidden Performance Problem
&lt;/h2&gt;

&lt;p&gt;When you do:&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;useState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;current&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;initialValue&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;JavaScript still &lt;strong&gt;recreates that object on every single render&lt;/strong&gt;, even&lt;br&gt;
though React only uses the initial value on the first render.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;  unnecessary object allocations\&lt;/li&gt;
&lt;li&gt;  extra CPU work during render\&lt;/li&gt;
&lt;li&gt;  increased garbage-collection pressure\&lt;/li&gt;
&lt;li&gt;  wasted memory churn\&lt;/li&gt;
&lt;li&gt;  unnecessary strain in fast or frequently updating UI sections&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Visualizing the Flow
&lt;/h2&gt;

&lt;p&gt;Your code:&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;useState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;current&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;initialValue&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Render cycle:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Render 1:&lt;/strong&gt; - JS creates &lt;code&gt;{ current: initialValue }&lt;/code&gt; - React uses it&lt;br&gt;
as the initial state&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Render 2:&lt;/strong&gt; - JS creates &lt;code&gt;{ current: initialValue }&lt;/code&gt; again - React&lt;br&gt;
ignores it&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Render 3:&lt;/strong&gt; - JS creates &lt;code&gt;{ current: initialValue }&lt;/code&gt; again - React&lt;br&gt;
ignores it&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Render 30:&lt;/strong&gt; - JS creates &lt;code&gt;{ current: initialValue }&lt;/code&gt; again - React&lt;br&gt;
ignores it&lt;/p&gt;

&lt;h2&gt;
  
  
  The Fix: Lazy Initialization
&lt;/h2&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="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="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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;current&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;initialValue&lt;/span&gt; &lt;span class="p"&gt;}));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why this is better?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  React calls the initializer &lt;strong&gt;only once&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;  No repeated object creation&lt;/li&gt;
&lt;li&gt;  No extra GC churn&lt;/li&gt;
&lt;li&gt;  No hidden allocations in later renders&lt;/li&gt;
&lt;li&gt;  Matches &lt;code&gt;useRef()&lt;/code&gt; behavior&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Performance Advantages
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  Reduced render cost\&lt;/li&gt;
&lt;li&gt;  Lower GC pressure\&lt;/li&gt;
&lt;li&gt;  Optimized initialization\&lt;/li&gt;
&lt;li&gt;  Less memory churn\&lt;/li&gt;
&lt;li&gt;  More predictable rerenders&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Author
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Yogesh Bamanier&lt;/strong&gt;\&lt;br&gt;
Sr Frontend Engineer | React Performance Enthusiast&lt;/p&gt;

&lt;p&gt;LinkedIn: &lt;a href="https://www.linkedin.com/in/yogesh-007" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/yogesh-007&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>react</category>
    </item>
    <item>
      <title>🚀 How React Keeps Your UI Smooth: Fiber Architecture, Scheduler &amp; Priority Lanes Explained</title>
      <dc:creator>Yogesh Bamanier</dc:creator>
      <pubDate>Thu, 09 Oct 2025 16:51:39 +0000</pubDate>
      <link>https://forem.com/yorgie7/react-scheduler-lanes-the-ultimate-guide-to-smooth-ui-1gmk</link>
      <guid>https://forem.com/yorgie7/react-scheduler-lanes-the-ultimate-guide-to-smooth-ui-1gmk</guid>
      <description>&lt;h2&gt;
  
  
  🎬 React Scheduler &amp;amp; Lanes – The Ultimate Guide to Smooth UI
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Ever wondered how React keeps your UI responsive — even when handling massive updates or long lists?&lt;/em&gt; 🤔&lt;/p&gt;

&lt;p&gt;Let’s explore &lt;strong&gt;React’s Fiber architecture&lt;/strong&gt;, &lt;strong&gt;Scheduler&lt;/strong&gt;, and &lt;strong&gt;Priority Lanes&lt;/strong&gt;, explained with official concepts, analogies, and examples. 🎭&lt;/p&gt;




&lt;h2&gt;
  
  
  🎜️ 1️⃣ Root Creation – Setting the Stage
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&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;react&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="nx"&gt;ReactDOM&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;react-dom/client&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="nx"&gt;App&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;./App&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;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createRoot&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="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;root&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;App&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;createRoot()&lt;/code&gt; → creates a &lt;strong&gt;FiberRoot&lt;/strong&gt;, the backstage manager 🎟️&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.render()&lt;/code&gt; → schedules the first render&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💡 &lt;strong&gt;Official Concept:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The FiberRoot is the central object managing rendering work. Think of it as React’s &lt;strong&gt;director notebook&lt;/strong&gt; 📝.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🌳 2️⃣ Fiber Tree – The Actors on Stage
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FiberRoot
 ├─ App (Parent)
 │   ├─ Header
 │   ├─ Content
 │   │   ├─ Sidebar
 │   │   └─ Main
 │   └─ Footer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each &lt;strong&gt;Fiber node&lt;/strong&gt; tracks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Component type&lt;/li&gt;
&lt;li&gt;Props &amp;amp; state&lt;/li&gt;
&lt;li&gt;Parent/child/sibling relationships&lt;/li&gt;
&lt;li&gt;Priority lane info&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💡 &lt;strong&gt;Fiber enables incremental rendering&lt;/strong&gt;, breaking updates into small chunks so your UI never freezes.&lt;/p&gt;

&lt;p&gt;🎭 &lt;em&gt;Analogy:&lt;/em&gt; Each Fiber is an actor waiting for cues from the director (FiberRoot).&lt;/p&gt;




&lt;h2&gt;
  
  
  🎩 3️⃣ Scheduler – The Movie Producer
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;Scheduler&lt;/strong&gt; decides which updates run first based on their &lt;strong&gt;priority&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Enables &lt;strong&gt;cooperative scheduling&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Splits work into chunks so the UI stays responsive&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💡 &lt;strong&gt;Official Insight:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The Scheduler manages work according to priority lanes, ensuring critical updates happen first while background work waits.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🛣️ 4️⃣ Lanes – Priority Highways
&lt;/h2&gt;

&lt;p&gt;Lanes represent &lt;strong&gt;different priority levels&lt;/strong&gt; for updates:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Lane&lt;/th&gt;
&lt;th&gt;Priority&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SyncLane&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Immediate&lt;/td&gt;
&lt;td&gt;Button clicks, form submissions 🚀&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;InputContinuousLane&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;Typing in inputs ✍️&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;DefaultLane&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Normal&lt;/td&gt;
&lt;td&gt;Data fetching 📦&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;IdleLane&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;Background tasks 🌙&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;💡 &lt;strong&gt;React’s secret sauce:&lt;/strong&gt; Lanes let React categorize work by urgency — critical updates don’t get blocked by slower ones.&lt;/p&gt;




&lt;h3&gt;
  
  
  ⚙️ 4a. Handling Updates in Lanes
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nf"&gt;setSearchQuery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// High-priority&lt;/span&gt;
&lt;span class="nf"&gt;setData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fetchedData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;    &lt;span class="c1"&gt;// Normal-priority&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Typing updates instantly&lt;br&gt;
⏳ Data fetch updates in background&lt;/p&gt;

&lt;p&gt;React’s Scheduler always picks &lt;strong&gt;the highest-priority lane first&lt;/strong&gt;, keeping interactions smooth.&lt;/p&gt;




&lt;h3&gt;
  
  
  🔗 4b. Combining Updates
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nf"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;(&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;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;setFlag&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;When updates are in the &lt;strong&gt;same lane&lt;/strong&gt;, they merge and run together — &lt;strong&gt;no flicker, no unnecessary re-renders&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎥 5️⃣ Rendering Flow – Behind the Scenes
&lt;/h2&gt;

&lt;p&gt;React rendering happens in two main phases:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Render Phase&lt;/strong&gt; → Compute changes (builds work-in-progress Fiber tree)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Commit Phase&lt;/strong&gt; → Apply side effects and update the DOM&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;💡 &lt;em&gt;Official Note:&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Render phase = pure computation&lt;br&gt;
Commit phase = DOM mutations + effects&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  ✨ 6️⃣ Example – Priority Lanes in Action
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useTransition&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;react&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;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="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="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;list&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setList&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="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;isPending&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;startTransition&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useTransition&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="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;setCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;c&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="c1"&gt;// SyncLane ⚡&lt;/span&gt;
    &lt;span class="nf"&gt;startTransition&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="c1"&gt;// DefaultLane 🐢&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bigList&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="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10000&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`Item &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;i&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="nf"&gt;setList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bigList&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;&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;&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;handleClick&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Click me&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="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Count: &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;count&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;p&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;isPending&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;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Loading...&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&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;&lt;/span&gt;&lt;span class="nt"&gt;ul&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;list&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;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;li&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;item&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;item&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;li&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;/&lt;/span&gt;&lt;span class="nt"&gt;ul&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Immediate updates use &lt;strong&gt;SyncLane&lt;/strong&gt; ⚡&lt;/li&gt;
&lt;li&gt;Heavy background updates use &lt;strong&gt;DefaultLane&lt;/strong&gt; 🐢&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ The UI remains &lt;strong&gt;buttery smooth&lt;/strong&gt;, even while rendering 10,000 items.&lt;/p&gt;

&lt;p&gt;💡 &lt;em&gt;Tip:&lt;/em&gt; Use &lt;code&gt;useTransition&lt;/code&gt; to mark non-urgent updates.&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 7️⃣ Why Priority Lanes Matter
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Prevent &lt;strong&gt;janky UI&lt;/strong&gt; 🖌️&lt;/li&gt;
&lt;li&gt;Enable &lt;strong&gt;concurrent rendering&lt;/strong&gt; 🔄&lt;/li&gt;
&lt;li&gt;Keep &lt;strong&gt;interactions responsive&lt;/strong&gt; ✨&lt;/li&gt;
&lt;li&gt;Reduce &lt;strong&gt;layout thrashing&lt;/strong&gt; 🞗️&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🎜️ 8️⃣ React as a Movie Analogy
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;React Concept&lt;/th&gt;
&lt;th&gt;Analogy&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;FiberRoot&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Director’s notebook 💓&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Fibers&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Actors on stage 🎭&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Scheduler&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Producer deciding scene order 🎩&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Lanes&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Priority highways 🛣️&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Commit Phase&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Final cut, scenes go live 🎮&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  ✅ Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fiber architecture&lt;/strong&gt; → Breaks work into small, interruptible units&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scheduler&lt;/strong&gt; → Manages updates based on priority&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Priority Lanes&lt;/strong&gt; → Classify updates by urgency&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;useTransition&lt;/strong&gt; → Marks non-urgent work&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Goal:&lt;/strong&gt; High-priority updates never wait → &lt;strong&gt;smooth UI always&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔥 TL;DR
&lt;/h2&gt;

&lt;p&gt;React is like a movie set 🎮:&lt;/p&gt;

&lt;p&gt;⚡ Urgent scenes (high-priority updates) shoot first&lt;br&gt;
🐢 Slow scenes (background updates) wait&lt;br&gt;
🎯 The audience (user) always sees a smooth experience&lt;/p&gt;




&lt;p&gt;📝 &lt;strong&gt;Written by:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Yogesh Bamanier&lt;/strong&gt; – Senior Frontend Developer | ReactJS &amp;amp; Advanced JavaScript Enthusiast | Building Smooth, Performant UIs 🚀&lt;/p&gt;

&lt;p&gt;💬 Connect with me on &lt;a href="https://www.linkedin.com/in/yogesh-007/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; for more React deep dives!&lt;/p&gt;




&lt;p&gt;**#ReactJS #JavaScript #WebDevelopment #FrontendDevelopment #ReactFiber #ReactConcurrentMode #ReactHooks #ReactPerformance #WebPerformance #UIUX #FrontendArchitecture #WebDevTips #LearnReact #De&lt;/p&gt;

</description>
      <category>react</category>
      <category>architecture</category>
      <category>performance</category>
      <category>javascript</category>
    </item>
    <item>
      <title>🔥 Master ES6 in JavaScript: From Basics to Pro with Real-World Examples 💻</title>
      <dc:creator>Yogesh Bamanier</dc:creator>
      <pubDate>Thu, 02 Oct 2025 20:21:06 +0000</pubDate>
      <link>https://forem.com/yorgie7/master-es6-in-javascript-from-basics-to-pro-with-real-world-examples-47o6</link>
      <guid>https://forem.com/yorgie7/master-es6-in-javascript-from-basics-to-pro-with-real-world-examples-47o6</guid>
      <description>&lt;h2&gt;
  
  
  🚀 &lt;strong&gt;ES6 Explained: The Complete Modern JavaScript Guide Every Developer Needs ⚡&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;JavaScript got its biggest upgrade with &lt;strong&gt;ES6 (ECMAScript 2015)&lt;/strong&gt; 🎉✨. These modern features make our code &lt;strong&gt;cleaner, faster, and more powerful&lt;/strong&gt;. Whether you’re a beginner or a pro, mastering ES6 is a must for building scalable applications 💻🔥.&lt;/p&gt;




&lt;h2&gt;
  
  
  ✨ &lt;strong&gt;1. &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; New ways to declare variables (&lt;strong&gt;block-scoped&lt;/strong&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; Use &lt;code&gt;let&lt;/code&gt; when variable values change, and &lt;code&gt;const&lt;/code&gt; when they don’t.
&lt;/li&gt;
&lt;/ul&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;counter&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;API_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://api.example.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;counter&lt;/span&gt;&lt;span class="o"&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;Prevents accidental overwrites, makes code predictable.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Pro Tip:&lt;/strong&gt; Always use &lt;code&gt;const&lt;/code&gt; by default and switch to &lt;code&gt;let&lt;/code&gt; only when reassignment is needed.&lt;/p&gt;




&lt;h2&gt;
  
  
  📝 &lt;strong&gt;2. Template Literals&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; Backtick (`) strings with embedded expressions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; For cleaner string concatenation and multi-line support.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;js&lt;br&gt;
const name = "Yogesh";&lt;br&gt;
console.log(&lt;/code&gt;Hello, ${name}! Welcome 🚀&lt;code&gt;);&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;🔥 &lt;strong&gt;Makes strings more readable and dynamic.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;📝 &lt;strong&gt;Note:&lt;/strong&gt; You can even use them for generating HTML templates dynamically.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎯 &lt;strong&gt;3. Arrow Functions&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; A shorter syntax for writing functions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; Great for callbacks and functional programming.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;js&lt;br&gt;
const numbers = [1, 2, 3];&lt;br&gt;
const squares = numbers.map(n =&amp;gt; n * n);&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;⚡ &lt;strong&gt;They also preserve &lt;code&gt;this&lt;/code&gt; binding.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Pro Tip:&lt;/strong&gt; Avoid arrow functions when you need access to &lt;code&gt;arguments&lt;/code&gt; or dynamic &lt;code&gt;this&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ &lt;strong&gt;4. Default Parameters&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; Function parameters with default values.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; Avoids errors when arguments are missing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;js&lt;br&gt;
function greet(name = "Guest") {&lt;br&gt;
  return&lt;/code&gt;Hello, ${name}&lt;code&gt;;&lt;br&gt;
}&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;🎉 &lt;strong&gt;Cleaner fallback handling.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  📦 &lt;strong&gt;5. Rest &amp;amp; Spread Operators&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; &lt;code&gt;...&lt;/code&gt; collects/rests parameters or spreads values.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; Flexible handling of arrays and objects.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`js&lt;br&gt;
// Spread&lt;br&gt;
const arr = [1, 2, 3];&lt;br&gt;
const arr2 = [...arr, 4, 5];&lt;/p&gt;

&lt;p&gt;// Rest&lt;br&gt;
function sum(...nums) {&lt;br&gt;
  return nums.reduce((a, b) =&amp;gt; a + b, 0);&lt;br&gt;
}&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;⚡ &lt;strong&gt;Makes code shorter and powerful.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;📝 &lt;strong&gt;Note:&lt;/strong&gt; Spread is especially useful when working with immutable state in React apps.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧩 &lt;strong&gt;6. Destructuring Assignment&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; Extract values from arrays/objects easily.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; Cleaner code with direct variable mapping.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;js&lt;br&gt;
const user = { name: "Yogesh", age: 25 };&lt;br&gt;
const { name, age } = user;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;🎯 &lt;strong&gt;Improves readability.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Pro Tip:&lt;/strong&gt; Combine destructuring with default values for safer code.&lt;/p&gt;




&lt;h2&gt;
  
  
  🏗️ &lt;strong&gt;7. Enhanced Object Literals&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; Shorter syntax for defining objects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; Useful in APIs and config objects.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;js&lt;br&gt;
let age = 25;&lt;br&gt;
const person = { name: "Yogesh", age, greet() { return "Hi"; } };&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;🔥 &lt;strong&gt;Reduces boilerplate code.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🏛️ &lt;strong&gt;8. Classes &amp;amp; Inheritance&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; ES6 syntax for OOP in JS.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; Organizing code in reusable blueprints.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;js&lt;br&gt;
class Animal {&lt;br&gt;
  constructor(name) { this.name = name; }&lt;br&gt;
  speak() { console.log(&lt;/code&gt;${this.name} makes a sound`); }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;class Dog extends Animal {&lt;br&gt;
  speak() { console.log(&lt;code&gt;${this.name} barks 🐶&lt;/code&gt;); }&lt;br&gt;
}&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;⚡ &lt;strong&gt;Cleaner and more structured OOP.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;📝 &lt;strong&gt;Note:&lt;/strong&gt; Classes are syntactic sugar over prototypes.&lt;/p&gt;




&lt;h2&gt;
  
  
  📚 &lt;strong&gt;9. Modules (&lt;code&gt;import&lt;/code&gt; / &lt;code&gt;export&lt;/code&gt;)&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; Built-in modular programming.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; Split large codebases into reusable files.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`js&lt;br&gt;
// math.js&lt;br&gt;
export const add = (a, b) =&amp;gt; a + b;&lt;/p&gt;

&lt;p&gt;// app.js&lt;br&gt;
import { add } from './math.js';&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;🎉 &lt;strong&gt;Encourages maintainable code.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Pro Tip:&lt;/strong&gt; Use default exports when exporting a single main function or class.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⏳ &lt;strong&gt;10. Promises&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; Objects for async operations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; Handle APIs, I/O, network requests.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;js&lt;br&gt;
fetch("/data.json")&lt;br&gt;
  .then(res =&amp;gt; res.json())&lt;br&gt;
  .then(data =&amp;gt; console.log(data))&lt;br&gt;
  .catch(err =&amp;gt; console.error(err));&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;🔥 &lt;strong&gt;Replaces messy callback chains.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;📝 &lt;strong&gt;Note:&lt;/strong&gt; Always handle &lt;code&gt;.catch()&lt;/code&gt; to avoid unhandled promise rejections.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔁 &lt;strong&gt;11. Iterators &amp;amp; Generators&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; Iterators define sequence, Generators simplify creation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; Custom iteration logic.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;js&lt;br&gt;
function* numbersGen() {&lt;br&gt;
  yield 1;&lt;br&gt;
  yield 2;&lt;br&gt;
}&lt;br&gt;
for (let n of numbersGen()) console.log(n);&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;⚡ &lt;strong&gt;Control over iteration flow.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🌀 &lt;strong&gt;12. Symbols&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; Unique and immutable identifiers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; Avoid property collisions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;js&lt;br&gt;
const id = Symbol("id");&lt;br&gt;
const user = { [id]: 123 };&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;🎯 &lt;strong&gt;Perfect for hidden object keys.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Pro Tip:&lt;/strong&gt; Great for creating private object properties.&lt;/p&gt;




&lt;h2&gt;
  
  
  🗺️ &lt;strong&gt;13. Maps &amp;amp; Sets&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; New data structures.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; Efficient storage.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`js&lt;br&gt;
let map = new Map();&lt;br&gt;
map.set("name", "Yogesh");&lt;/p&gt;

&lt;p&gt;let set = new Set([1,2,3,3]); // {1,2,3}&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;🔥 &lt;strong&gt;Better than plain objects for collections.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🔒 &lt;strong&gt;14. WeakMaps &amp;amp; WeakSets&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; Similar to Maps/Sets but with weak references.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; Useful for memory-sensitive caching.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;js&lt;br&gt;
let weakMap = new WeakMap();&lt;br&gt;
const obj = {};&lt;br&gt;
weakMap.set(obj, "data");&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;⚡ &lt;strong&gt;Prevents memory leaks.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;📝 &lt;strong&gt;Note:&lt;/strong&gt; Keys in WeakMaps must be objects.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚡ &lt;strong&gt;15. Async/Await (ES2017 but often taught with ES6)&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; Syntactic sugar over Promises.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; Write async code like synchronous.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;js&lt;br&gt;
async function fetchData() {&lt;br&gt;
  try {&lt;br&gt;
    const res = await fetch("/data.json");&lt;br&gt;
    const data = await res.json();&lt;br&gt;
    console.log(data);&lt;br&gt;
  } catch (err) {&lt;br&gt;
    console.error(err);&lt;br&gt;
  }&lt;br&gt;
}&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;🎉 &lt;strong&gt;Cleaner async programming.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Pro Tip:&lt;/strong&gt; Use &lt;code&gt;try...catch&lt;/code&gt; with &lt;code&gt;await&lt;/code&gt; to handle errors gracefully.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎇 &lt;strong&gt;Final Thoughts&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;ES6 transformed JavaScript into a &lt;strong&gt;modern, developer-friendly language&lt;/strong&gt; 🚀. From &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; to async handling, these features power today’s frameworks like &lt;strong&gt;React, Vue, and Angular&lt;/strong&gt;. Mastering them makes you a &lt;strong&gt;better web developer&lt;/strong&gt; ⚡🔥.&lt;/p&gt;

&lt;p&gt;👉 Written By: &lt;a href="https://www.linkedin.com/in/yogesh-007/" rel="noopener noreferrer"&gt;Yogesh Bamanier&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>🚀 How the Browser Pre-Resource Loader Works: A Deep Dive 🖥️</title>
      <dc:creator>Yogesh Bamanier</dc:creator>
      <pubDate>Tue, 30 Sep 2025 18:19:15 +0000</pubDate>
      <link>https://forem.com/yorgie7/how-the-browser-pre-resource-loader-works-a-deep-dive-3nkm</link>
      <guid>https://forem.com/yorgie7/how-the-browser-pre-resource-loader-works-a-deep-dive-3nkm</guid>
      <description>&lt;h2&gt;
  
  
  A tale behind Speculative parser.
&lt;/h2&gt;

&lt;p&gt;Discover how the browser pre-resource loader works alongside the HTML parser to fetch assets early. ⚡&lt;br&gt;
Learn how this mechanism ensures faster, smoother, and visually complete web pages. 🌐&lt;/p&gt;


&lt;h2&gt;
  
  
  🌟 Introduction: The Race for Speed 🏁
&lt;/h2&gt;

&lt;p&gt;Modern web pages are full of images, fonts, scripts, and styles. Delivering content quickly is critical for &lt;strong&gt;user experience and SEO&lt;/strong&gt;. 🚀&lt;/p&gt;

&lt;p&gt;Browsers use a smart feature called the &lt;strong&gt;pre-resource loader&lt;/strong&gt;, a parallel helper that works with the &lt;strong&gt;HTML parser&lt;/strong&gt; to make pages appear almost instantly. Think of it as a behind-the-scenes assistant preparing resources &lt;strong&gt;before the main parser even needs them&lt;/strong&gt;. 🕵️‍♂️&lt;/p&gt;


&lt;h2&gt;
  
  
  🧩 Understanding the HTML Parser 📝
&lt;/h2&gt;

&lt;p&gt;The HTML parser is the &lt;strong&gt;brain&lt;/strong&gt; that reads your HTML document &lt;strong&gt;line by line&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tokenization:&lt;/strong&gt; Breaks HTML into meaningful units (&lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt;). 🏷️&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DOM Tree Construction:&lt;/strong&gt; Converts tokens into DOM nodes, creating the structure of the page. 🌳&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CSS Parsing &amp;amp; Style Resolution:&lt;/strong&gt; Builds the CSSOM tree to compute styles for elements. 🎨&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Script Handling:&lt;/strong&gt; Pauses parsing for blocking &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tags to maintain DOM correctness. ⏸️&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; Without preloading, the parser triggers resource downloads &lt;strong&gt;only when it encounters them&lt;/strong&gt;, slowing down page rendering. 🐢&lt;/p&gt;


&lt;h2&gt;
  
  
  ⚡ The Pre-Resource Loader: Your Page’s Secret Assistant 🤖
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;pre-resource loader&lt;/strong&gt; works in parallel with the main parser. Its mission: &lt;strong&gt;speculate which resources will be needed next&lt;/strong&gt; and fetch them &lt;strong&gt;asynchronously&lt;/strong&gt;, so they are ready exactly when required.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How It Works:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Speculative Parsing:&lt;/strong&gt; A lightweight &lt;strong&gt;parallel parser&lt;/strong&gt; scans ahead to find images, stylesheets, scripts, and fonts. 🔍&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resource Prioritization:&lt;/strong&gt; Determines &lt;strong&gt;critical vs. non-critical resources&lt;/strong&gt;, giving high priority to the most important assets. 🏆&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Early Fetching:&lt;/strong&gt; Downloads assets &lt;strong&gt;before the main parser reaches them&lt;/strong&gt;. ⏩&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integration with Main Parser:&lt;/strong&gt; When the parser reaches a resource, it is often &lt;strong&gt;already loaded or partially loaded&lt;/strong&gt;, drastically reducing render-blocking delays. ✅&lt;/li&gt;
&lt;/ol&gt;


&lt;h2&gt;
  
  
  🌐 Preloading Techniques 🛠️
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;&amp;lt;link rel="preload"&amp;gt;&lt;/code&gt;&lt;/strong&gt; → Fetch critical resources early (fonts, hero images, key scripts). 📥&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;&amp;lt;link rel="prefetch"&amp;gt;&lt;/code&gt;&lt;/strong&gt; → Fetch resources likely needed for the &lt;strong&gt;next page navigation&lt;/strong&gt;. 🔮&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;&amp;lt;link rel="preconnect"&amp;gt;&lt;/code&gt;&lt;/strong&gt; → Opens network connections early (DNS, TCP, TLS handshake). 🌐&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Async &amp;amp; Defer Scripts&lt;/strong&gt; → Allow JavaScript to download without blocking parsing. ⏱️&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;⚡ &lt;strong&gt;Pro Tip:&lt;/strong&gt; Overusing preloading can backfire by consuming unnecessary network bandwidth. Use it selectively for &lt;strong&gt;critical path resources&lt;/strong&gt;. ⚠️&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h2&gt;
  
  
  🖼 Why the Pre-Resource Loader Matters 🎯
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Faster Rendering:&lt;/strong&gt; Resources are fetched ahead of time, making pages appear faster. 🏎️&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Smooth Animations:&lt;/strong&gt; Fonts, images, and CSS are ready when needed, avoiding “flash of unstyled content” (FOUC). 🎬&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reduced Render-Blocking:&lt;/strong&gt; Critical resources load in parallel, keeping the page interactive. ⚡&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Better UX &amp;amp; SEO:&lt;/strong&gt; Faster visual completion improves engagement and search ranking. 📈&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  🎨 Story Analogy: The Chef &amp;amp; the Assistant 👨‍🍳
&lt;/h2&gt;

&lt;p&gt;Imagine the HTML parser as a &lt;strong&gt;chef reading a recipe&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Without preloading, the chef gathers each ingredient &lt;strong&gt;only when needed&lt;/strong&gt;, wasting time. ⏳&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;pre-resource loader&lt;/strong&gt; acts like an &lt;strong&gt;assistant who prepares ingredients in advance&lt;/strong&gt;, ensuring the chef can cook continuously and efficiently. 🥘&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Multiple assistants handling &lt;strong&gt;spices, vegetables, and utensils simultaneously&lt;/strong&gt; is analogous to &lt;strong&gt;how modern browsers fetch multiple resources in parallel&lt;/strong&gt;. 🧑‍🍳&lt;/p&gt;


&lt;h2&gt;
  
  
  🔄 Behind the Scenes: Speculative Parsing + Preloading ⚙️
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Workflow Diagram (simplified):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTML Parser
    │
    ▼
Speculative Parser (Parallel)
    │
    ▼
Pre-Resource Loader → Resource Downloader (Images, Fonts, CSS, JS)
    │
    ▼
DOM Tree + CSSOM → Layered Painting → GPU Compositing → Screen
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;HTML Parser:&lt;/strong&gt; Builds the DOM structure. 🏗️&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Speculative Parser:&lt;/strong&gt; Scans ahead to detect resources early. 🔎&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pre-Resource Loader:&lt;/strong&gt; Initiates early downloads. ⬇️&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GPU Compositing:&lt;/strong&gt; Paints layers efficiently for smooth rendering. 🎨&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ✅ Conclusion 🏁
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;pre-resource loader&lt;/strong&gt; is a hidden hero of modern web performance. By working alongside the &lt;strong&gt;HTML parser&lt;/strong&gt;, it ensures that &lt;strong&gt;critical assets are ready exactly when needed&lt;/strong&gt;, enabling &lt;strong&gt;fast, smooth, and seamless web experiences&lt;/strong&gt;. 🌟&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SEO Keywords:&lt;/strong&gt; Browser pre-resource loader, speculative parser, HTML parser optimization, preload CSS/JS/images, fast web page rendering, smooth animations, web performance.&lt;/p&gt;




&lt;p&gt;✍️ &lt;em&gt;Written by Yogesh Bamanier&lt;/em&gt;&lt;br&gt;
🔗 &lt;a href="https://www.linkedin.com/in/yogesh-007/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;/p&gt;

</description>
      <category>html</category>
      <category>frontend</category>
      <category>performance</category>
      <category>architecture</category>
    </item>
    <item>
      <title>🖼️ From Pixels to Performance: Understanding Layers in Web Rendering</title>
      <dc:creator>Yogesh Bamanier</dc:creator>
      <pubDate>Tue, 30 Sep 2025 17:45:10 +0000</pubDate>
      <link>https://forem.com/yorgie7/from-pixels-to-performance-understanding-layers-in-web-rendering-42cf</link>
      <guid>https://forem.com/yorgie7/from-pixels-to-performance-understanding-layers-in-web-rendering-42cf</guid>
      <description>&lt;h1&gt;
  
  
  Understanding Layers in Web Rendering: From CPU to GPU 🚀
&lt;/h1&gt;

&lt;p&gt;"Explore how web browsers use layers to optimize rendering, reduce repaint costs, and improve performance. 🖥️✨"⚡🖌️&lt;/p&gt;

&lt;h2&gt;
  
  
  📝 Introduction
&lt;/h2&gt;

&lt;p&gt;Modern web applications are complex, and rendering efficiently is crucial for a smooth user experience. One of the most important concepts in browser performance is &lt;strong&gt;layering&lt;/strong&gt;. Layers allow the browser to isolate parts of the page, optimize rendering, and leverage the GPU for faster compositing. 🖥️💨&lt;/p&gt;

&lt;p&gt;Rendering a webpage involves multiple steps, including parsing HTML, applying CSS, building the render tree, layout calculations, painting, and finally compositing layers. Layers help browsers manage these steps efficiently by separating independent components that can be updated without redrawing the entire page.&lt;/p&gt;




&lt;h2&gt;
  
  
  🖼️ What Are Layers?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;layer&lt;/strong&gt; is a separate plane that the browser can paint and composite independently. Instead of repainting the entire page when a small change happens, the browser can repaint just the affected layer. Layers are especially useful for animations, transitions, and complex visual effects.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;✅ **Why use layers?&lt;/em&gt;* &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduce expensive repaints. 💰&lt;/li&gt;
&lt;li&gt;Enable GPU acceleration. ⚡&lt;/li&gt;
&lt;li&gt;Improve animations and scrolling performance. 🎢&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Layers also help prevent layout thrashing, a common performance bottleneck where the browser continuously recalculates layouts due to DOM changes. By isolating elements in their own layers, browsers can minimize these recalculations and maintain smoother interactions.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔍 How Layers Work: Step by Step
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. CPU → Layer Painting 🎨
&lt;/h3&gt;

&lt;p&gt;The CPU is responsible for computing styles, layouts, and painting content into layers. This involves several sub-steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Style calculation:&lt;/strong&gt; Determines computed styles for each element.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Layout:&lt;/strong&gt; Calculates the position and size of each element.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Painting:&lt;/strong&gt; Converts elements into pixels on layers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The browser may create multiple layers for elements with &lt;code&gt;position: fixed&lt;/code&gt;, &lt;code&gt;transform&lt;/code&gt;, &lt;code&gt;opacity&lt;/code&gt;, &lt;code&gt;will-change&lt;/code&gt;, and other properties that trigger layer promotion.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. GPU → Compositing 🖌️
&lt;/h3&gt;

&lt;p&gt;Once layers are painted, they are sent to the GPU for compositing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GPU combines layers efficiently to create the final frame.&lt;/li&gt;
&lt;li&gt;Offloading work to the GPU reduces CPU usage.&lt;/li&gt;
&lt;li&gt;Smooth animations are possible because layers can be moved or transformed without repainting the entire page.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Final Frame 🖥️
&lt;/h3&gt;

&lt;p&gt;Composited layers are displayed on the screen. Only layers that change need to be re-composited, which greatly improves rendering performance.&lt;/p&gt;

&lt;p&gt;This separation between painting and compositing is critical for web performance, especially on devices with limited CPU power but strong GPU capabilities, like mobile phones and tablets.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚡ When to Use Layers
&lt;/h2&gt;

&lt;p&gt;Creating layers strategically can enhance performance:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Transformations and animations (&lt;code&gt;translate&lt;/code&gt;, &lt;code&gt;scale&lt;/code&gt;, &lt;code&gt;rotate&lt;/code&gt;) 🔄&lt;/li&gt;
&lt;li&gt;Fixed or sticky headers 📌&lt;/li&gt;
&lt;li&gt;Elements with &lt;code&gt;opacity&lt;/code&gt; transitions 🌫️&lt;/li&gt;
&lt;li&gt;Complex visual effects ✨&lt;/li&gt;
&lt;li&gt;Video playback or canvas elements 🎥&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; Overusing layers can backfire — too many layers consume GPU memory and may actually reduce performance. Monitor layer count using Chrome DevTools to find the optimal balance.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ Common Layer Issues and Solutions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Excessive Layer Count
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Problem:&lt;/strong&gt; Too many elements promoted to layers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; Only promote elements that benefit from independent compositing, e.g., animations.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Jank During Animation
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Problem:&lt;/strong&gt; Layer not promoted, causing CPU-intensive repaints.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; Use &lt;code&gt;will-change: transform&lt;/code&gt; or &lt;code&gt;translateZ(0)&lt;/code&gt; to hint the browser to create a layer.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Memory Usage
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Problem:&lt;/strong&gt; Each layer consumes GPU memory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; Remove unnecessary layers and optimize textures for images or canvas.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Visual Diagram (CPU🔄 → Layers 🖼️ → GPU 🎨 → Screen 🖥️)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[CPU] → [Paint Layers] → [Send to GPU] → [Composite Layers] → [Screen]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each box represents a critical stage in browser rendering. Layers help divide the work efficiently between CPU and GPU. 🏗️ This process ensures smooth scrolling, animations, and transitions, even in complex web applications.&lt;/p&gt;




&lt;h2&gt;
  
  
  SEO Keywords to Boost Ranking 🔑
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Web performance optimization 🚀&lt;/li&gt;
&lt;li&gt;Browser rendering layers 🖼️&lt;/li&gt;
&lt;li&gt;GPU compositing 🎨&lt;/li&gt;
&lt;li&gt;Smooth CSS animations ✨&lt;/li&gt;
&lt;li&gt;Reduce repaint cost 💰&lt;/li&gt;
&lt;li&gt;Rendering pipeline optimization 🖥️&lt;/li&gt;
&lt;li&gt;Web animation performance 🎢&lt;/li&gt;
&lt;li&gt;CSS transforms and layers 🔄&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Conclusion 🎯
&lt;/h2&gt;

&lt;p&gt;Layers are a powerful tool in the browser rendering pipeline. By understanding &lt;strong&gt;when and how to create layers&lt;/strong&gt;, you can optimize web applications for speed, smoother animations, and better user experience. 🌟&lt;/p&gt;

&lt;p&gt;Mastering layers also helps in debugging rendering issues, improving frame rates, and providing consistent performance across devices.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Written by:&lt;/strong&gt; Yogesh Bamanier ✍️&lt;br&gt;
Senior Frontend Developer | React &amp;amp; JavaScript Expert | Web Performance Enthusiast | Open-Source Contributor | Tech Blogger | Passionate about high-performance web apps 🚀&lt;/p&gt;

</description>
      <category>html</category>
      <category>frontend</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>⚡ The Power Behind Web Animations: GPU’s Role in the Critical Rendering Path 🖼️</title>
      <dc:creator>Yogesh Bamanier</dc:creator>
      <pubDate>Tue, 30 Sep 2025 17:20:58 +0000</pubDate>
      <link>https://forem.com/yorgie7/the-power-behind-web-animations-gpus-role-in-the-critical-rendering-path-27hg</link>
      <guid>https://forem.com/yorgie7/the-power-behind-web-animations-gpus-role-in-the-critical-rendering-path-27hg</guid>
      <description>&lt;p&gt;✨ &lt;strong&gt;Ever wondered what really makes web animations buttery smooth at 60fps?&lt;/strong&gt; While the CPU handles parsing your &lt;strong&gt;HTML&lt;/strong&gt;, &lt;strong&gt;CSS&lt;/strong&gt;, and JavaScript, the &lt;strong&gt;GPU steps in as the true power behind animations&lt;/strong&gt; — ensuring frames render every ~16ms, layers are composited seamlessly, and your web app feels alive. In this post, we’ll take you from zero to hero 🚀, breaking down the critical rendering path, CPU vs GPU responsibilities, and how to optimize animations for maximum performance.&lt;/p&gt;




&lt;h2&gt;
  
  
  👶 Stage 1: The Basics (CPU’s Job)
&lt;/h2&gt;

&lt;p&gt;The browser starts by crunching through your code:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;📝 &lt;strong&gt;HTML Parse → DOM Tree&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;🎨 &lt;strong&gt;CSS Parse → CSSOM Tree&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;🧩 &lt;strong&gt;DOM + CSSOM → Render Tree&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;📐 &lt;strong&gt;Layout&lt;/strong&gt; (geometry, positions)&lt;/li&gt;
&lt;li&gt;🖌️ &lt;strong&gt;Paint&lt;/strong&gt; (draw each element)&lt;/li&gt;
&lt;li&gt;🧩 &lt;strong&gt;Composite&lt;/strong&gt; (put it all together)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;At this point, the &lt;strong&gt;CPU is the main actor&lt;/strong&gt; — parsing, calculating, and deciding what should appear.&lt;/p&gt;




&lt;h2&gt;
  
  
  🦸 Stage 2: Enter the GPU (The Hero)
&lt;/h2&gt;

&lt;p&gt;The GPU swoops in ⚡ during the later stages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🎭 &lt;strong&gt;Rasterization&lt;/strong&gt;: turns paint instructions into actual pixels on screen.&lt;/li&gt;
&lt;li&gt;🖼️ &lt;strong&gt;Compositing&lt;/strong&gt;: merges layers (images, videos, transforms) for the final frame.&lt;/li&gt;
&lt;li&gt;🏎️ &lt;strong&gt;Animations&lt;/strong&gt; using &lt;code&gt;transform&lt;/code&gt; &amp;amp; &lt;code&gt;opacity&lt;/code&gt;: handled directly by the GPU → buttery smooth 60fps.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💡 Think of the CPU as the &lt;strong&gt;director&lt;/strong&gt; and the GPU as the &lt;strong&gt;special effects artist&lt;/strong&gt; making everything shine.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎨 Stage 3: The Animation Dilemma
&lt;/h2&gt;

&lt;p&gt;Not all animations are created equal:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;❌ &lt;strong&gt;CPU-heavy:&lt;/strong&gt; &lt;code&gt;width: 200px → 300px&lt;/code&gt;&lt;br&gt;
→ triggers layout → repaint → GPU composites → can drop frames (not hitting 60fps).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;✅ &lt;strong&gt;GPU-friendly:&lt;/strong&gt; &lt;code&gt;transform: translateX(100px)&lt;/code&gt;&lt;br&gt;
→ skips layout → GPU moves layer directly → stays locked at 60fps.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔄 Stage 4: The Rendering Pipeline (Zero → Hero)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CPU → DOM/CSSOM → Render Tree → Layout
                ↓
           Paint (CPU → GPU)
                ↓
           Rasterization (GPU)
                ↓
           Compositing (GPU)
                ↓
        🎉 Display Frame @ ~16ms (60fps)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is where the &lt;strong&gt;hand-off&lt;/strong&gt; happens: CPU does the planning, GPU does the magic.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔋 Stage 5: The Power Story
&lt;/h2&gt;

&lt;p&gt;Animations consume power, especially on mobile:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🔥 &lt;strong&gt;CPU-bound animations&lt;/strong&gt; (&lt;code&gt;width&lt;/code&gt;, &lt;code&gt;height&lt;/code&gt;, &lt;code&gt;margin&lt;/code&gt;) → more battery drain, dropped frames.&lt;/li&gt;
&lt;li&gt;🌱 &lt;strong&gt;GPU-accelerated animations&lt;/strong&gt; (&lt;code&gt;transform&lt;/code&gt;, &lt;code&gt;opacity&lt;/code&gt;) → power-efficient, steady 60fps experience.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s why accessibility features like &lt;strong&gt;“Reduce Motion”&lt;/strong&gt; exist — saving battery and helping users.&lt;/p&gt;




&lt;h2&gt;
  
  
  🏆 Stage 6: The Hero’s Guide (Best Practices)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;🪄 Animate with &lt;strong&gt;&lt;code&gt;transform&lt;/code&gt; and &lt;code&gt;opacity&lt;/code&gt;&lt;/strong&gt; for GPU acceleration.&lt;/li&gt;
&lt;li&gt;🚫 Avoid animating layout-affecting properties like &lt;code&gt;width&lt;/code&gt;, &lt;code&gt;top&lt;/code&gt;, &lt;code&gt;margin&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;🕵️ Use &lt;strong&gt;Chrome DevTools → Performance tab&lt;/strong&gt; to monitor 16ms frame deadlines.&lt;/li&gt;
&lt;li&gt;📱 Test on low-end devices to ensure 60fps real-world smoothness.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  🌟 Final Words
&lt;/h2&gt;

&lt;p&gt;The GPU doesn’t parse your HTML or CSS. But when it comes to painting, compositing, and animating — the GPU is the &lt;strong&gt;true hero&lt;/strong&gt; that powers smooth web experiences at 60fps ✨.&lt;/p&gt;

&lt;p&gt;Next time you build an animation, remember: &lt;strong&gt;let the GPU do the heavy lifting.&lt;/strong&gt; 💪&lt;/p&gt;




&lt;p&gt;✍️ &lt;em&gt;Written by Yogesh Bamanier — Frontend Developer &amp;amp; Web Performance Enthusiast&lt;/em&gt; 🚀&lt;/p&gt;

&lt;h1&gt;
  
  
  WebPerformance #GPUAcceleration #Rendering #Frontend #JavaScript #CSS #60fps #CriticalRenderingPath #BrowserInternals #DevTools
&lt;/h1&gt;

</description>
      <category>webdev</category>
      <category>html</category>
      <category>css</category>
      <category>web</category>
    </item>
    <item>
      <title>🌐 Understanding Gateway Errors (500, 502, 503, 504) — An Expert End-to-End Guide for Developers ⚡</title>
      <dc:creator>Yogesh Bamanier</dc:creator>
      <pubDate>Mon, 29 Sep 2025 20:40:00 +0000</pubDate>
      <link>https://forem.com/yorgie7/understanding-gateway-errors-500-502-503-504-an-expert-end-to-end-guide-for-developers-2dp1</link>
      <guid>https://forem.com/yorgie7/understanding-gateway-errors-500-502-503-504-an-expert-end-to-end-guide-for-developers-2dp1</guid>
      <description>&lt;h2&gt;
  
  
  🚀 Struggling with 500, 502, 503, or 504 errors? Here’s the ultimate guide to debugging HTTP gateway errors like a pro! 🔗
&lt;/h2&gt;

&lt;p&gt;If you’re a &lt;strong&gt;developer, DevOps engineer, or site reliability engineer&lt;/strong&gt;, chances are you’ve encountered cryptic errors like &lt;strong&gt;500 Internal Server Error&lt;/strong&gt;, &lt;strong&gt;502 Bad Gateway&lt;/strong&gt;, &lt;strong&gt;503 Service Unavailable&lt;/strong&gt;, or &lt;strong&gt;504 Gateway Timeout&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This blog dives deep into &lt;strong&gt;what these HTTP gateway errors mean, why they happen, and how to fix them&lt;/strong&gt;. By the end, you’ll have a clear mental model to debug faster and explain these issues like an expert. 🚀&lt;/p&gt;




&lt;h2&gt;
  
  
  🔑 What is a Gateway in Web Architecture?
&lt;/h2&gt;

&lt;p&gt;In modern web infrastructure, a &lt;strong&gt;gateway&lt;/strong&gt; is a &lt;strong&gt;server that sits between the client (browser, mobile app, API consumer) and your backend services&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It acts as a &lt;strong&gt;reverse proxy, load balancer, or API gateway&lt;/strong&gt; to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Receive requests 🌍&lt;/li&gt;
&lt;li&gt;Route them to the correct app server 🔀&lt;/li&gt;
&lt;li&gt;Collect responses and send them back 📦&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Examples of gateways:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;NGINX / Apache HTTPD (reverse proxies)&lt;/li&gt;
&lt;li&gt;AWS Elastic Load Balancer / Google Cloud Load Balancer&lt;/li&gt;
&lt;li&gt;API Gateways (Kong, Apigee, AWS API Gateway)&lt;/li&gt;
&lt;li&gt;CDNs like Cloudflare, Akamai, Fastly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Optimizing your gateway setup is crucial for &lt;strong&gt;website performance, SEO rankings, and uptime reliability&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  📌 How Requests Flow Through Gateways
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client (Browser / App)
       |
       v
   Gateway (Load Balancer / Proxy)
       |
       v
   Application Server (Node.js, Django, Java, etc.)
       |
       v
 Database / External Services
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each layer introduces potential &lt;strong&gt;bottlenecks or failures&lt;/strong&gt;, leading to errors.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔍 Gateway Errors Explained
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1️⃣ 500 Internal Server Error
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Where it happens:&lt;/strong&gt; Inside the &lt;strong&gt;application server&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cause:&lt;/strong&gt; Unhandled exceptions, bugs, or misconfigurations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Example:&lt;/strong&gt; Null pointer exception in Java or runtime crash in Node.js.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ &lt;strong&gt;Fix:&lt;/strong&gt; Debug and patch your application code.&lt;/p&gt;




&lt;h3&gt;
  
  
  2️⃣ 502 Bad Gateway
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Where it happens:&lt;/strong&gt; Gateway ↔ App server connection.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cause:&lt;/strong&gt; Gateway gets an invalid response from the server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Example:&lt;/strong&gt; App server down, misconfigured proxy, or corrupt response.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ &lt;strong&gt;Fix:&lt;/strong&gt; Verify upstream servers and network configs.&lt;/p&gt;




&lt;h3&gt;
  
  
  3️⃣ 503 Service Unavailable
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Where it happens:&lt;/strong&gt; The upstream server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cause:&lt;/strong&gt; Server overloaded, under maintenance, or scaling delays.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Example:&lt;/strong&gt; Too many requests flood a single backend.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ &lt;strong&gt;Fix:&lt;/strong&gt; Scale horizontally, add caching, or use rate limiting.&lt;/p&gt;




&lt;h3&gt;
  
  
  4️⃣ 504 Gateway Timeout
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Where it happens:&lt;/strong&gt; Gateway waiting for upstream.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cause:&lt;/strong&gt; The server took too long to respond.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Example:&lt;/strong&gt; Slow database queries, third-party API delays, backend deadlocks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ &lt;strong&gt;Fix:&lt;/strong&gt; Optimize queries, add caching, or increase timeout settings.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚖️ Quick Comparison — 500 vs 502 vs 503 vs 504
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Error Code&lt;/th&gt;
&lt;th&gt;Where it Fails&lt;/th&gt;
&lt;th&gt;Root Cause&lt;/th&gt;
&lt;th&gt;Example Scenario&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;500&lt;/strong&gt; Internal Server Error&lt;/td&gt;
&lt;td&gt;App server&lt;/td&gt;
&lt;td&gt;Bug, crash, misconfig&lt;/td&gt;
&lt;td&gt;Null pointer, unhandled promise&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;502&lt;/strong&gt; Bad Gateway&lt;/td&gt;
&lt;td&gt;Gateway to server link&lt;/td&gt;
&lt;td&gt;Invalid response&lt;/td&gt;
&lt;td&gt;App crashed, bad proxy config&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;503&lt;/strong&gt; Service Unavailable&lt;/td&gt;
&lt;td&gt;Upstream server&lt;/td&gt;
&lt;td&gt;Overload, downtime&lt;/td&gt;
&lt;td&gt;Maintenance window, traffic spikes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;504&lt;/strong&gt; Gateway Timeout&lt;/td&gt;
&lt;td&gt;Gateway waiting&lt;/td&gt;
&lt;td&gt;Slow backend&lt;/td&gt;
&lt;td&gt;DB query taking 30s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  🚀 Why This Matters for SEO &amp;amp; Performance
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Search engines like Google penalize websites&lt;/strong&gt; that frequently serve 500+ errors.&lt;/li&gt;
&lt;li&gt;Gateway issues impact &lt;strong&gt;Core Web Vitals&lt;/strong&gt;, user experience, and bounce rates.&lt;/li&gt;
&lt;li&gt;A site plagued with &lt;strong&gt;502/503/504 errors&lt;/strong&gt; will rank lower in &lt;strong&gt;Google Search results&lt;/strong&gt; and lose traffic.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 By fixing these errors, you improve not just uptime, but also &lt;strong&gt;SEO rankings, conversion rates, and user trust&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🏆 Final Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;500&lt;/strong&gt; → Debug your &lt;strong&gt;application code&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;502&lt;/strong&gt; → Fix &lt;strong&gt;upstream connectivity/configs&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;503&lt;/strong&gt; → Handle &lt;strong&gt;overloads and maintenance&lt;/strong&gt; better.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;504&lt;/strong&gt; → Optimize &lt;strong&gt;backend performance&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Mastering gateway error handling is a &lt;strong&gt;critical DevOps skill&lt;/strong&gt; that helps build &lt;strong&gt;resilient, SEO-friendly, high-performance web applications&lt;/strong&gt;.&lt;/p&gt;




&lt;p&gt;✍️ Written by &lt;em&gt;Yogesh Bamanier&lt;/em&gt;&lt;br&gt;
🔗 &lt;a href="https://www.linkedin.com/in/yogesh-bamanier" rel="noopener noreferrer"&gt;Connect with me on LinkedIn&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📢 &lt;em&gt;If you found this helpful, share it on LinkedIn/Twitter to help others debug faster!&lt;/em&gt; 🚀&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ai</category>
      <category>backend</category>
      <category>restapi</category>
    </item>
    <item>
      <title>🧩 Understanding `isNaN()` vs `Number.isNaN()` in JavaScript – Complete Guide</title>
      <dc:creator>Yogesh Bamanier</dc:creator>
      <pubDate>Mon, 29 Sep 2025 09:35:27 +0000</pubDate>
      <link>https://forem.com/yorgie7/numberisnan-vs-isnan-in-javascript-explained-36a9</link>
      <guid>https://forem.com/yorgie7/numberisnan-vs-isnan-in-javascript-explained-36a9</guid>
      <description>&lt;p&gt;&lt;strong&gt;Short Description:&lt;/strong&gt; Learn the key differences between &lt;code&gt;isNaN()&lt;/code&gt; and &lt;code&gt;Number.isNaN()&lt;/code&gt; in JavaScript. Understand type coercion, pitfalls, and best practices for handling &lt;code&gt;NaN&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keywords:&lt;/strong&gt; JavaScript &lt;code&gt;isNaN()&lt;/code&gt;, &lt;code&gt;Number.isNaN()&lt;/code&gt;, type coercion, NaN handling, JavaScript numbers, ES6&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 Introduction
&lt;/h2&gt;

&lt;p&gt;In JavaScript, handling &lt;strong&gt;&lt;code&gt;NaN&lt;/code&gt; (Not-a-Number)&lt;/strong&gt; values is a common source of confusion.&lt;/p&gt;

&lt;p&gt;We have two different methods for checking &lt;code&gt;NaN&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;isNaN()&lt;/code&gt;&lt;/strong&gt; – the older, global function.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;Number.isNaN()&lt;/code&gt;&lt;/strong&gt; – introduced in ES6 to fix &lt;code&gt;isNaN()&lt;/code&gt; quirks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s break them down with examples and comparisons 👇&lt;/p&gt;




&lt;h2&gt;
  
  
  📌 What is &lt;code&gt;isNaN()&lt;/code&gt;?
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;isNaN()&lt;/code&gt; function checks whether a value is &lt;code&gt;NaN&lt;/code&gt;. But before doing so, it &lt;strong&gt;tries to convert the value into a number&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Syntax:&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;isNaN&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Behavior:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;true&lt;/code&gt; → if the converted value is &lt;code&gt;NaN&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;false&lt;/code&gt; → if the converted value is a valid number.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Example:&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;isNaN&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="c1"&gt;// false → "2" → 2&lt;/span&gt;
&lt;span class="nf"&gt;isNaN&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;abc&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true  → cannot convert → NaN&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  📌 What is &lt;code&gt;Number.isNaN()&lt;/code&gt;?
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;&lt;code&gt;Number.isNaN()&lt;/code&gt;&lt;/strong&gt; method was introduced in &lt;strong&gt;ES6&lt;/strong&gt;. Unlike &lt;code&gt;isNaN()&lt;/code&gt;, it &lt;strong&gt;does not coerce values&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Syntax:&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="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isNaN&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Behavior:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Returns &lt;code&gt;true&lt;/code&gt; &lt;strong&gt;only if the value is literally NaN&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;No type conversion happens.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Example:&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;Number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isNaN&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="c1"&gt;// false → it's a string&lt;/span&gt;
&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isNaN&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;abc&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// false → still a string&lt;/span&gt;
&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isNaN&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;NaN&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="c1"&gt;// true  → exactly NaN&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  ⚖️ Comparison: &lt;code&gt;isNaN()&lt;/code&gt; vs &lt;code&gt;Number.isNaN()&lt;/code&gt;
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;th&gt;&lt;code&gt;isNaN(value)&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;&lt;code&gt;Number.isNaN(value)&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;Why?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;NaN&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✅ true&lt;/td&gt;
&lt;td&gt;✅ true&lt;/td&gt;
&lt;td&gt;Both detect actual NaN&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;"123"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;❌ false&lt;/td&gt;
&lt;td&gt;❌ false&lt;/td&gt;
&lt;td&gt;String → number works&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;"ABC"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✅ true&lt;/td&gt;
&lt;td&gt;❌ false&lt;/td&gt;
&lt;td&gt;Global &lt;code&gt;isNaN&lt;/code&gt; coerces, &lt;code&gt;Number.isNaN&lt;/code&gt; does not&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;undefined&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✅ true&lt;/td&gt;
&lt;td&gt;❌ false&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;undefined → NaN&lt;/code&gt; via coercion&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;null&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;❌ false&lt;/td&gt;
&lt;td&gt;❌ false&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;null → 0&lt;/code&gt; when coerced&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;{}&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✅ true&lt;/td&gt;
&lt;td&gt;❌ false&lt;/td&gt;
&lt;td&gt;Object → NaN in coercion&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;[]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;❌ false&lt;/td&gt;
&lt;td&gt;❌ false&lt;/td&gt;
&lt;td&gt;Empty array → 0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;true&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;❌ false&lt;/td&gt;
&lt;td&gt;❌ false&lt;/td&gt;
&lt;td&gt;&lt;code&gt;true → 1&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  📝 Examples Side by Side
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Classic isNaN()&lt;/span&gt;
&lt;span class="nf"&gt;isNaN&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&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;      &lt;span class="c1"&gt;// true  → coerced into NaN&lt;/span&gt;
&lt;span class="nf"&gt;isNaN&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;    &lt;span class="c1"&gt;// true  → coerced into NaN&lt;/span&gt;

&lt;span class="c1"&gt;// Modern Number.isNaN()&lt;/span&gt;
&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isNaN&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&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="c1"&gt;// false → it's a string&lt;/span&gt;
&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isNaN&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// false → it's undefined&lt;/span&gt;
&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isNaN&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;NaN&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;       &lt;span class="c1"&gt;// true  → only works for NaN&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🎯 Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;isNaN()&lt;/code&gt;&lt;/strong&gt; → coerces values before checking → can give unexpected results.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;Number.isNaN()&lt;/code&gt;&lt;/strong&gt; → strict check → only returns true for real &lt;code&gt;NaN&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;✅ Best Practice: Always prefer &lt;strong&gt;&lt;code&gt;Number.isNaN()&lt;/code&gt;&lt;/strong&gt; in modern JavaScript for reliability.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;✍️ &lt;strong&gt;Written by Yogesh Bamanier&lt;/strong&gt;&lt;br&gt;
🔗 &lt;a href="https://www.linkedin.com/in/yogeshbamanier/" rel="noopener noreferrer"&gt;Connect with me on LinkedIn&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>webdev</category>
      <category>development</category>
    </item>
    <item>
      <title>React Synthetic Events Explained: Complete Guide for Developers ⚡</title>
      <dc:creator>Yogesh Bamanier</dc:creator>
      <pubDate>Mon, 29 Sep 2025 08:54:53 +0000</pubDate>
      <link>https://forem.com/yorgie7/react-synthetic-events-explained-complete-guide-for-developers-3o2j</link>
      <guid>https://forem.com/yorgie7/react-synthetic-events-explained-complete-guide-for-developers-3o2j</guid>
      <description>&lt;h2&gt;
  
  
  React Synthetic Events Explained: Complete Guide for Developers ⚡
&lt;/h2&gt;

&lt;p&gt;Learn everything about &lt;strong&gt;React Synthetic Events&lt;/strong&gt;, how they work, and why they are essential for building efficient and interactive React applications. This guide covers examples, event pooling, and best practices for developers.&lt;/p&gt;

&lt;p&gt;Imagine your web page is a &lt;strong&gt;party 🎉&lt;/strong&gt; with buttons, inputs, and forms all interacting.&lt;/p&gt;

&lt;p&gt;Instead of listening to every single element, React has a &lt;strong&gt;Synthetic Event butler&lt;/strong&gt; who:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Listens to all events&lt;/li&gt;
&lt;li&gt;Keeps messages consistent across browsers 🌐&lt;/li&gt;
&lt;li&gt;Sends them neatly to your handler 📨&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;React plays a &lt;strong&gt;central role&lt;/strong&gt; in this system. It &lt;strong&gt;intercepts native DOM events&lt;/strong&gt;, wraps them into &lt;strong&gt;Synthetic Events&lt;/strong&gt;, and manages how they are delivered to your components. By doing this, React ensures that events are &lt;strong&gt;handled efficiently, consistently, and with minimal memory usage&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  1️⃣ What Are React Synthetic Events?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;React Synthetic Events&lt;/strong&gt; are like &lt;strong&gt;magic envelopes ✉️&lt;/strong&gt; that wrap native browser events (clicks, keypresses, form changes). They ensure &lt;strong&gt;cross-browser compatibility&lt;/strong&gt;, making your React app more reliable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Button&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;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="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;Message from the Synthetic Event 🕴️:&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="nx"&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;return&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;handleClick&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Click Me!&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;p&gt;React &lt;strong&gt;actively monitors all interactions&lt;/strong&gt;, and when a user clicks, types, or submits a form, React decides &lt;strong&gt;how and when your component should respond&lt;/strong&gt;, using its internal event system.&lt;/p&gt;




&lt;h2&gt;
  
  
  2️⃣ How React Handles Events 🖱️
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;User interacts with an element 🖱️&lt;/li&gt;
&lt;li&gt;Native DOM event bubbles up 🌊&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;React intercepts&lt;/strong&gt; it at the root level&lt;/li&gt;
&lt;li&gt;Wraps it in a &lt;strong&gt;Synthetic Event&lt;/strong&gt; ✉️&lt;/li&gt;
&lt;li&gt;Delivered to your component’s handler 💌&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Flow:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[User Interaction] → [DOM Event] → [React Interception] → [Synthetic Event] → [Handler]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;React manages this flow to ensure &lt;strong&gt;performance and consistency&lt;/strong&gt;, reducing the need for multiple event listeners and handling event delegation behind the scenes.&lt;/p&gt;




&lt;h2&gt;
  
  
  3️⃣ Event Pooling in React ♻️
&lt;/h2&gt;

&lt;p&gt;React recycles Synthetic Events to save memory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handleClick&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="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;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;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ❌ Might be null!&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use &lt;code&gt;event.persist()&lt;/code&gt; to keep the event alive 🌱:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handleClick&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;persist&lt;/span&gt;&lt;span class="p"&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;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;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ✅ Works perfectly&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  4️⃣ Common React Synthetic Event Types 🕺💃
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mouse Events:&lt;/strong&gt; &lt;code&gt;onClick&lt;/code&gt;, &lt;code&gt;onMouseEnter&lt;/code&gt;, &lt;code&gt;onMouseLeave&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keyboard Events:&lt;/strong&gt; &lt;code&gt;onKeyDown&lt;/code&gt;, &lt;code&gt;onKeyPress&lt;/code&gt;, &lt;code&gt;onKeyUp&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Form Events:&lt;/strong&gt; &lt;code&gt;onChange&lt;/code&gt;, &lt;code&gt;onSubmit&lt;/code&gt;, &lt;code&gt;onInput&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Focus Events:&lt;/strong&gt; &lt;code&gt;onFocus&lt;/code&gt;, &lt;code&gt;onBlur&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Touch Events:&lt;/strong&gt; &lt;code&gt;onTouchStart&lt;/code&gt;, &lt;code&gt;onTouchEnd&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  5️⃣ Benefits of React Synthetic Events ❤️
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Cross-browser consistency 🪄&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Memory-efficient 🧠&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Unified API for all events ✨&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;React-controlled delivery&lt;/strong&gt; ensures components respond correctly and efficiently.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  6️⃣ Best Practices for Developers 🛠️
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Use &lt;code&gt;persist()&lt;/code&gt; only when necessary.&lt;/li&gt;
&lt;li&gt;Keep event handlers simple 🍬.&lt;/li&gt;
&lt;li&gt;Stop propagation carefully.&lt;/li&gt;
&lt;li&gt;Combine Synthetic Events with controlled forms for better performance 📝.&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  Conclusion 💡
&lt;/h3&gt;

&lt;p&gt;React Synthetic Events are a &lt;strong&gt;powerful tool&lt;/strong&gt; for handling user interactions efficiently. React not only &lt;strong&gt;wraps and manages native events&lt;/strong&gt;, but it also ensures your components &lt;strong&gt;receive consistent, high-performance events&lt;/strong&gt;, making your apps reliable and interactive.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Written by Yogesh Bamanier&lt;/em&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>reactnative</category>
      <category>reactjsdevelopment</category>
      <category>javascript</category>
    </item>
    <item>
      <title>✨ React Patterns Every Expert Should Master 🧩🪝</title>
      <dc:creator>Yogesh Bamanier</dc:creator>
      <pubDate>Fri, 26 Sep 2025 13:49:21 +0000</pubDate>
      <link>https://forem.com/yorgie7/react-patterns-every-expert-should-master-3efp</link>
      <guid>https://forem.com/yorgie7/react-patterns-every-expert-should-master-3efp</guid>
      <description>&lt;p&gt;React isn’t just about writing components—it’s about writing them in &lt;strong&gt;scalable, reusable, and maintainable&lt;/strong&gt; ways. That’s where &lt;strong&gt;design patterns&lt;/strong&gt; come in. Let’s explore the &lt;strong&gt;most important React patterns&lt;/strong&gt;, with examples, real-world use cases, and why they matter. 🌟&lt;/p&gt;




&lt;h2 id="1-container-presentational-pattern-"&gt;1️⃣ Container &amp;amp; Presentational Pattern 🧑‍💻🎨&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Container Components&lt;/strong&gt;: Handle data fetching, state, business logic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Presentational Components&lt;/strong&gt;: Handle UI rendering only.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 &lt;strong&gt;Use Case&lt;/strong&gt;: Keeps code clean by separating &lt;strong&gt;logic&lt;/strong&gt; from &lt;strong&gt;UI&lt;/strong&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-comment"&gt;// Presentational&lt;/span&gt;
&lt;span class="hljs-keyword"&gt;const&lt;/span&gt; UserList = &lt;span class="hljs-function"&gt;(&lt;span&gt;{ users }&lt;/span&gt;) =&amp;gt;&lt;/span&gt; (
  &lt;span class="xml"&gt;&lt;span&gt;&amp;lt;&lt;span&gt;ul&lt;/span&gt;&amp;gt;&lt;/span&gt;{users.map(u =&amp;gt; &lt;span&gt;&amp;lt;&lt;span&gt;li&lt;/span&gt; &lt;span&gt;key&lt;/span&gt;=&lt;span&gt;{u.id}&lt;/span&gt;&amp;gt;&lt;/span&gt;{u.name}&lt;span&gt;&amp;lt;/&lt;span&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;)}&lt;span&gt;&amp;lt;/&lt;span&gt;ul&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
);

&lt;span class="hljs-comment"&gt;// Container&lt;/span&gt;
&lt;span class="hljs-keyword"&gt;const&lt;/span&gt; UserListContainer = &lt;span class="hljs-function"&gt;&lt;span&gt;()&lt;/span&gt; =&amp;gt;&lt;/span&gt; {
  &lt;span class="hljs-keyword"&gt;const&lt;/span&gt; [users, setUsers] = useState([]);
  useEffect(&lt;span class="hljs-function"&gt;&lt;span&gt;()&lt;/span&gt; =&amp;gt;&lt;/span&gt; {
    fetch(&lt;span class="hljs-string"&gt;"/api/users"&lt;/span&gt;).then(&lt;span class="hljs-function"&gt;&lt;span&gt;res&lt;/span&gt; =&amp;gt;&lt;/span&gt; res.json()).then(setUsers);
  }, []);
  &lt;span class="hljs-keyword"&gt;return&lt;/span&gt; &lt;span class="xml"&gt;&lt;span&gt;&amp;lt;&lt;span&gt;UserList&lt;/span&gt; &lt;span&gt;users&lt;/span&gt;=&lt;span&gt;{users}&lt;/span&gt; /&amp;gt;&lt;/span&gt;;
};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;✅ &lt;strong&gt;Real-world&lt;/strong&gt;: A &lt;code&gt;UserProfile&lt;/code&gt; component only displays data, while &lt;code&gt;UserProfileContainer&lt;/code&gt; fetches from an API.&lt;/p&gt;




&lt;h2 id="2-higher-order-components-hoc-"&gt;2️⃣ Higher-Order Components (HOC) 🔁&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;function that takes a component and returns a new component&lt;/strong&gt; with extended functionality.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Use Case&lt;/strong&gt;: Code reuse (e.g., authentication, logging, theming).&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;const withLogger = &lt;span class="hljs-function"&gt;&lt;span&gt;(Wrapped)&lt;/span&gt; =&amp;gt;&lt;/span&gt; (props) =&amp;gt; {
  useEffect(&lt;span class="hljs-function"&gt;&lt;span&gt;()&lt;/span&gt; =&amp;gt;&lt;/span&gt; &lt;span class="hljs-built_in"&gt;console&lt;/span&gt;.log(&lt;span class="hljs-string"&gt;"Mounted:"&lt;/span&gt;, Wrapped.name), []);
  &lt;span class="hljs-keyword"&gt;return&lt;/span&gt; &amp;lt;Wrapped {...props} /&amp;gt;;
};

const Profile = &lt;span class="hljs-function"&gt;&lt;span&gt;()&lt;/span&gt; =&amp;gt;&lt;/span&gt; &amp;lt;h2&amp;gt;My Profile&amp;lt;/h2&amp;gt;;
export default withLogger(Profile);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;✅ &lt;strong&gt;Real-world&lt;/strong&gt;: &lt;code&gt;withAuth&lt;/code&gt; HOC to protect routes.&lt;/p&gt;




&lt;h2 id="3-render-props-"&gt;3️⃣ Render Props 🎭&lt;/h2&gt;

&lt;p&gt;A pattern where a component’s child is a function that receives state/logic.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Use Case&lt;/strong&gt;: Share behavior without inheritance or HOCs.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-keyword"&gt;const&lt;/span&gt; MouseTracker = &lt;span class="hljs-function"&gt;(&lt;span&gt;{ children }&lt;/span&gt;) =&amp;gt;&lt;/span&gt; {
  &lt;span class="hljs-keyword"&gt;const&lt;/span&gt; [pos, setPos] = useState({ &lt;span class="hljs-attr"&gt;x&lt;/span&gt;: &lt;span class="hljs-number"&gt;0&lt;/span&gt;, &lt;span class="hljs-attr"&gt;y&lt;/span&gt;: &lt;span class="hljs-number"&gt;0&lt;/span&gt; });
  &lt;span class="hljs-keyword"&gt;return&lt;/span&gt; (
    &lt;span class="xml"&gt;&lt;span&gt;&amp;lt;&lt;span&gt;div&lt;/span&gt; &lt;span&gt;onMouseMove&lt;/span&gt;=&lt;span&gt;{(e)&lt;/span&gt; =&amp;gt;&lt;/span&gt; setPos({ x: e.clientX, y: e.clientY })}&amp;gt;
      {children(pos)}
    &lt;span&gt;&amp;lt;/&lt;span&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
  );
};

&lt;span class="xml"&gt;&lt;span&gt;&amp;lt;&lt;span&gt;MouseTracker&lt;/span&gt;&amp;gt;&lt;/span&gt;
  {({ x, y }) =&amp;gt; &lt;span&gt;&amp;lt;&lt;span&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;🐭 Mouse: {x}, {y}&lt;span&gt;&amp;lt;/&lt;span&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;}
&lt;span&gt;&amp;lt;/&lt;span&gt;MouseTracker&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;✅ &lt;strong&gt;Real-world&lt;/strong&gt;: Tooltips, drag-and-drop, analytics tracking.&lt;/p&gt;




&lt;h2 id="4-custom-hooks-"&gt;4️⃣ Custom Hooks 🪝&lt;/h2&gt;

&lt;p&gt;Encapsulate logic in reusable hooks.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Use Case&lt;/strong&gt;: Extract stateful logic from components for reusability.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;const useFetch = &lt;span class="hljs-function"&gt;&lt;span&gt;(url)&lt;/span&gt; =&amp;gt;&lt;/span&gt; {
  const [data, setData] = useState(&lt;span class="hljs-literal"&gt;null&lt;/span&gt;);
  useEffect(&lt;span class="hljs-function"&gt;&lt;span&gt;()&lt;/span&gt; =&amp;gt;&lt;/span&gt; {
    fetch(url).&lt;span class="hljs-keyword"&gt;then&lt;/span&gt;(r =&amp;gt; r.json()).&lt;span class="hljs-keyword"&gt;then&lt;/span&gt;(setData);
  }, [url]);
  &lt;span class="hljs-keyword"&gt;return&lt;/span&gt; data;
};

const Posts = &lt;span class="hljs-function"&gt;&lt;span&gt;()&lt;/span&gt; =&amp;gt;&lt;/span&gt; {
  const posts = useFetch(&lt;span class="hljs-string"&gt;"/api/posts"&lt;/span&gt;);
  &lt;span class="hljs-keyword"&gt;return&lt;/span&gt; posts ? posts.map(p =&amp;gt; &amp;lt;p key={p.id}&amp;gt;{p.title}&amp;lt;/p&amp;gt;) : &lt;span class="hljs-string"&gt;"⏳ Loading..."&lt;/span&gt;;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;✅ &lt;strong&gt;Real-world&lt;/strong&gt;: &lt;code&gt;useAuth&lt;/code&gt;, &lt;code&gt;useLocalStorage&lt;/code&gt;, &lt;code&gt;useDebounce&lt;/code&gt;.&lt;/p&gt;




&lt;h2 id="5-compound-components-"&gt;5️⃣ Compound Components 🧩&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;set of components working together&lt;/strong&gt; to provide a flexible API.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Use Case&lt;/strong&gt;: Flexible UI libraries like &lt;code&gt;react-router&lt;/code&gt;, &lt;code&gt;headlessui&lt;/code&gt;, &lt;code&gt;Radix UI&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&lt;span class="xml"&gt;const Tabs = (&lt;/span&gt;&lt;span class="hljs-template-variable"&gt;{ children }&lt;/span&gt;&lt;span class="xml"&gt;) =&amp;gt; &lt;span&gt;&amp;lt;&lt;span&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="hljs-template-variable"&gt;{children}&lt;/span&gt;&lt;span class="xml"&gt;&lt;span&gt;&amp;lt;/&lt;span&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;;
Tabs.Tab = (&lt;/span&gt;&lt;span class="hljs-template-variable"&gt;{ children }&lt;/span&gt;&lt;span class="xml"&gt;) =&amp;gt; &lt;span&gt;&amp;lt;&lt;span&gt;button&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="hljs-template-variable"&gt;{children}&lt;/span&gt;&lt;span class="xml"&gt;&lt;span&gt;&amp;lt;/&lt;span&gt;button&lt;/span&gt;&amp;gt;&lt;/span&gt;;
Tabs.Panel = (&lt;/span&gt;&lt;span class="hljs-template-variable"&gt;{ children }&lt;/span&gt;&lt;span class="xml"&gt;) =&amp;gt; &lt;span&gt;&amp;lt;&lt;span&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="hljs-template-variable"&gt;{children}&lt;/span&gt;&lt;span class="xml"&gt;&lt;span&gt;&amp;lt;/&lt;span&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;;

&lt;span&gt;&amp;lt;&lt;span&gt;Tabs&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span&gt;&amp;lt;&lt;span&gt;Tabs.Tab&lt;/span&gt;&amp;gt;&lt;/span&gt;🏠 Home&lt;span&gt;&amp;lt;/&lt;span&gt;Tabs.Tab&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span&gt;&amp;lt;&lt;span&gt;Tabs.Tab&lt;/span&gt;&amp;gt;&lt;/span&gt;👤 Profile&lt;span&gt;&amp;lt;/&lt;span&gt;Tabs.Tab&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span&gt;&amp;lt;&lt;span&gt;Tabs.Panel&lt;/span&gt;&amp;gt;&lt;/span&gt;Content for Home&lt;span&gt;&amp;lt;/&lt;span&gt;Tabs.Panel&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span&gt;&amp;lt;&lt;span&gt;Tabs.Panel&lt;/span&gt;&amp;gt;&lt;/span&gt;Content for Profile&lt;span&gt;&amp;lt;/&lt;span&gt;Tabs.Panel&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span&gt;&amp;lt;/&lt;span&gt;Tabs&lt;/span&gt;&amp;gt;&lt;/span&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;✅ &lt;strong&gt;Real-world&lt;/strong&gt;: Dropdown menus, modals, stepper forms.&lt;/p&gt;




&lt;h2 id="6-context-api-provider-pattern-"&gt;6️⃣ Context API / Provider Pattern 🌐&lt;/h2&gt;

&lt;p&gt;Used to share state globally without prop drilling.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Use Case&lt;/strong&gt;: Themes, authentication, global settings.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-keyword"&gt;const&lt;/span&gt; ThemeContext = createContext(&lt;span class="hljs-string"&gt;"light"&lt;/span&gt;);

&lt;span class="hljs-keyword"&gt;const&lt;/span&gt; ThemeProvider = ({ children }) =&amp;gt; {
  &lt;span class="hljs-keyword"&gt;const&lt;/span&gt; [theme, setTheme] = useState(&lt;span class="hljs-string"&gt;"light"&lt;/span&gt;);
  &lt;span class="hljs-keyword"&gt;return&lt;/span&gt; (
    &amp;lt;ThemeContext.Provider value={{ theme, setTheme }}&amp;gt;
      {children}
    &amp;lt;/ThemeContext.Provider&amp;gt;
  );
};

&lt;span class="hljs-keyword"&gt;const&lt;/span&gt; ThemedButton = () =&amp;gt; {
  &lt;span class="hljs-keyword"&gt;const&lt;/span&gt; { theme } = useContext(ThemeContext);
  &lt;span class="hljs-keyword"&gt;return&lt;/span&gt; &amp;lt;button&amp;gt;{theme === &lt;span class="hljs-string"&gt;"light"&lt;/span&gt; ? &lt;span class="hljs-string"&gt;"☀️ Light Mode"&lt;/span&gt; : &lt;span class="hljs-string"&gt;"🌙 Dark Mode"&lt;/span&gt;}&amp;lt;/button&amp;gt;;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;✅ &lt;strong&gt;Real-world&lt;/strong&gt;: Dark/light mode, user sessions, language switch.&lt;/p&gt;




&lt;h2 id="7-controlled-vs-uncontrolled-components-"&gt;7️⃣ Controlled vs Uncontrolled Components 🎛️&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Controlled&lt;/strong&gt;: Form values controlled via React state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Uncontrolled&lt;/strong&gt;: Form values accessed via refs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 &lt;strong&gt;Use Case&lt;/strong&gt;: Controlled for validation, uncontrolled for performance/simple forms.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-comment"&gt;// Controlled&lt;/span&gt;
&amp;lt;&lt;span class="hljs-selector-tag"&gt;input&lt;/span&gt; value={value} onChange={(e) =&amp;gt; setValue(e&lt;span class="hljs-selector-class"&gt;.target&lt;/span&gt;&lt;span class="hljs-selector-class"&gt;.value&lt;/span&gt;)} /&amp;gt;

&lt;span class="hljs-comment"&gt;// Uncontrolled&lt;/span&gt;
&amp;lt;&lt;span class="hljs-selector-tag"&gt;input&lt;/span&gt; ref={ref} /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;✅ &lt;strong&gt;Real-world&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Controlled: Sign-up form with live validation.&lt;/li&gt;
&lt;li&gt;✅ Uncontrolled: File upload input.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2 id="8-state-reducer-pattern-"&gt;8️⃣ State Reducer Pattern ⚙️&lt;/h2&gt;

&lt;p&gt;Allow consumers to control internal state transitions (inspired by Redux).&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Use Case&lt;/strong&gt;: Complex reusable components where users need control.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function useToggle({ reducer = &lt;span class="hljs-function"&gt;&lt;span&gt;(s, a)&lt;/span&gt; =&amp;gt;&lt;/span&gt; !s } = {}) {
  const [&lt;span class="hljs-literal"&gt;on&lt;/span&gt;, dispatch] = useReducer(reducer, &lt;span class="hljs-literal"&gt;false&lt;/span&gt;);
  &lt;span class="hljs-keyword"&gt;return&lt;/span&gt; [&lt;span class="hljs-literal"&gt;on&lt;/span&gt;, &lt;span class="hljs-function"&gt;&lt;span&gt;()&lt;/span&gt; =&amp;gt;&lt;/span&gt; dispatch()];
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;✅ &lt;strong&gt;Real-world&lt;/strong&gt;: Customizable toggle, dropdown, or modal logic.&lt;/p&gt;




&lt;h2 id="9-controlled-props-pattern-"&gt;9️⃣ Controlled Props Pattern 🎚️&lt;/h2&gt;

&lt;p&gt;Component accepts both internal and external state control.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Use Case&lt;/strong&gt;: Library components needing flexible usage.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;const Toggle = &lt;span class="hljs-function"&gt;&lt;span&gt;({ &lt;span&gt;on&lt;/span&gt;: controlledOn, onChange })&lt;/span&gt; =&amp;gt;&lt;/span&gt; {
  const [uncontrolledOn, setOn] = useState(&lt;span class="hljs-literal"&gt;false&lt;/span&gt;);
  const isControlled = controlledOn !== &lt;span class="hljs-literal"&gt;undefined&lt;/span&gt;;
  const &lt;span class="hljs-literal"&gt;on&lt;/span&gt; = isControlled ? controlledOn : uncontrolledOn;

  const toggle = &lt;span class="hljs-function"&gt;&lt;span&gt;()&lt;/span&gt; =&amp;gt;&lt;/span&gt; {
    &lt;span class="hljs-keyword"&gt;if&lt;/span&gt; (isControlled) onChange(!&lt;span class="hljs-literal"&gt;on&lt;/span&gt;);
    &lt;span class="hljs-keyword"&gt;else&lt;/span&gt; setOn(!&lt;span class="hljs-literal"&gt;on&lt;/span&gt;);
  };

  &lt;span class="hljs-keyword"&gt;return&lt;/span&gt; &amp;lt;button onClick={toggle}&amp;gt;{&lt;span class="hljs-literal"&gt;on&lt;/span&gt; ? &lt;span class="hljs-string"&gt;"✅ ON"&lt;/span&gt; : &lt;span class="hljs-string"&gt;"❌ OFF"&lt;/span&gt;}&amp;lt;/button&amp;gt;;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;✅ &lt;strong&gt;Real-world&lt;/strong&gt;: Reusable toggle, form components, inputs.&lt;/p&gt;




&lt;h2 id="-hooks-state-machine-pattern-"&gt;🔟 Hooks State Machine Pattern 🕹️&lt;/h2&gt;

&lt;p&gt;Model component behavior with &lt;strong&gt;finite state machines&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Use Case&lt;/strong&gt;: Complex UI workflows with multiple states.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function useToggleMachine() {
  const [&lt;span class="hljs-keyword"&gt;state&lt;/span&gt;, &lt;span class="hljs-built_in"&gt;set&lt;/span&gt;State] = useState(&lt;span class="hljs-string"&gt;"off"&lt;/span&gt;);
  const toggle = () =&amp;gt; &lt;span class="hljs-built_in"&gt;set&lt;/span&gt;State(&lt;span class="hljs-keyword"&gt;state&lt;/span&gt; === &lt;span class="hljs-string"&gt;"off"&lt;/span&gt; ? &lt;span class="hljs-string"&gt;"on"&lt;/span&gt; : &lt;span class="hljs-string"&gt;"off"&lt;/span&gt;);
  return { &lt;span class="hljs-keyword"&gt;state&lt;/span&gt;, toggle };
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;✅ &lt;strong&gt;Real-world&lt;/strong&gt;: Payment flows 💳, multi-step onboarding 🪜, authentication 🔑.&lt;/p&gt;




&lt;h2 id="-choosing-the-right-react-pattern"&gt;🧭 Choosing the Right React Pattern&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;flowchart TD
    A[Start: Need to Share or Reuse Logic?] --&amp;gt;|&lt;span class="hljs-type"&gt;Yes&lt;/span&gt;| &lt;span class="hljs-type"&gt;B&lt;/span&gt;[Custom Hook]
    A --&amp;gt;|&lt;span class="hljs-type"&gt;No&lt;/span&gt;| &lt;span class="hljs-type"&gt;C&lt;/span&gt;[Need to Reuse UI?]

    C --&amp;gt;|&lt;span class="hljs-type"&gt;Yes&lt;/span&gt;| &lt;span class="hljs-type"&gt;D&lt;/span&gt;[Compound Components]
    C --&amp;gt;|&lt;span class="hljs-type"&gt;No&lt;/span&gt;| &lt;span class="hljs-type"&gt;E&lt;/span&gt;[Complex State Sharing?]

    E --&amp;gt;|&lt;span class="hljs-type"&gt;Yes&lt;/span&gt;| &lt;span class="hljs-type"&gt;F&lt;/span&gt;[&lt;span class="hljs-keyword"&gt;Context&lt;/span&gt; API / Provider Pattern]
    E --&amp;gt;|&lt;span class="hljs-type"&gt;No&lt;/span&gt;| &lt;span class="hljs-type"&gt;G&lt;/span&gt;[State &lt;span class="hljs-keyword"&gt;Local&lt;/span&gt; to Component]

    B --&amp;gt; H[Hook Reusable Across Components]
    D --&amp;gt; I[Flexible &amp;amp; Composable UI]
    F --&amp;gt; J[&lt;span class="hljs-keyword"&gt;Global&lt;/span&gt; State or Theme]
    G --&amp;gt; K[Simple useState Hook]
&lt;/code&gt;&lt;/pre&gt;




&lt;h1 id="-final-thoughts-"&gt;🏁 Final Thoughts ✨&lt;/h1&gt;

&lt;p&gt;Patterns are not just “nice to know”—they’re what separate &lt;strong&gt;good React developers&lt;/strong&gt; from &lt;strong&gt;great ones&lt;/strong&gt;.
By mastering them, you’ll build apps that scale gracefully, are easier to maintain, and provide cleaner APIs for your team and future self. 💡&lt;/p&gt;

&lt;p&gt;🔥 Start small, refactor incrementally, and let patterns emerge naturally.&lt;/p&gt;




&lt;h2 id="-about-the-author"&gt;📝 About the Author&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Written by &lt;a href="https://www.linkedin.com/in/yogesh-007/" rel="noopener noreferrer"&gt; &lt;strong&gt; Yogesh Bamanier&lt;/strong&gt;&lt;/a&gt;
Senior Frontend Developer | React.js Expert | Open-Source Contributor
Passionate about building scalable React applications and sharing knowledge with the dev community. 🚀&lt;/p&gt;


&lt;/blockquote&gt;





&lt;h2 id="-happy-learning-"&gt;🏷️📢 Happy-Learning...&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;#reactjs&lt;/li&gt;
&lt;li&gt;#javascript&lt;/li&gt;
&lt;li&gt;#frontend&lt;/li&gt;
&lt;li&gt;#webdev&lt;/li&gt;
&lt;li&gt;#reactpatterns&lt;/li&gt;
&lt;li&gt;#hooks&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Server Fallback in React SPAs (2025 Update): Prevent 404 Errors on Refresh 🚀</title>
      <dc:creator>Yogesh Bamanier</dc:creator>
      <pubDate>Wed, 24 Sep 2025 20:07:50 +0000</pubDate>
      <link>https://forem.com/yorgie7/server-fallback-in-react-spas-2025-update-prevent-404-errors-on-refresh-4ee8</link>
      <guid>https://forem.com/yorgie7/server-fallback-in-react-spas-2025-update-prevent-404-errors-on-refresh-4ee8</guid>
      <description>&lt;h1&gt;
  
  
  🚀 Understanding React Fiber: Incremental vs Concurrent Rendering
&lt;/h1&gt;

&lt;p&gt;React Fiber introduced a new way to handle rendering in React, allowing work to be &lt;strong&gt;split into small chunks (slices)&lt;/strong&gt;, &lt;strong&gt;paused&lt;/strong&gt;, &lt;strong&gt;resumed&lt;/strong&gt;, and even &lt;strong&gt;discarded&lt;/strong&gt;. But how does this affect what the browser actually sees? Let’s break it down.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧩 1. Work-in-Progress (WIP) and Slices
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Each &lt;strong&gt;Fiber node&lt;/strong&gt; is a unit of work.&lt;/li&gt;
&lt;li&gt;Rendering is divided into &lt;strong&gt;time slices&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;In each slice, React processes as many Fibers as it can before yielding back to the browser.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 &lt;strong&gt;Important&lt;/strong&gt;: Slices are only about preparing work. They do not directly affect the DOM.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛑 2. Pausing vs Discarding
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pausing&lt;/strong&gt; → If React runs out of time, it saves progress and continues in the next slice.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Discarding&lt;/strong&gt; → If a new higher-priority update comes in, React throws away unfinished WIP and restarts.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🎨 3. When Does the Browser See Updates?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;During Render (slices)&lt;/strong&gt; → React is only preparing the Fiber tree.
❌ No DOM updates yet.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;At Commit Phase&lt;/strong&gt; → React flushes the finished tree to the DOM in one atomic step.
✅ Browser paints changes here.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Even if rendering happens in &lt;strong&gt;5 slices&lt;/strong&gt;, the browser only updates &lt;strong&gt;after commit&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🌀 4. Why Is It Still Called Incremental Rendering?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;React doesn’t block the browser with a long, synchronous render.
&lt;/li&gt;
&lt;li&gt;Rendering work is split across slices.
&lt;/li&gt;
&lt;li&gt;Browser stays responsive in between.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🔑 The &lt;strong&gt;incremental part&lt;/strong&gt; is about &lt;strong&gt;time-slicing the render work&lt;/strong&gt;, not about incremental DOM commits.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔄 5. Example Walkthrough
&lt;/h2&gt;

&lt;p&gt;Imagine typing into an input that triggers a huge list render.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Without Fiber (old stack reconciler)&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Input change → whole list renders synchronously.
&lt;/li&gt;
&lt;li&gt;Browser frozen until work completes.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;With Fiber (incremental rendering)&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Slice 1: Input Fiber processed.
&lt;/li&gt;
&lt;li&gt;Yield → browser stays responsive.
&lt;/li&gt;
&lt;li&gt;Slice 2–5: List Fibers processed gradually.
&lt;/li&gt;
&lt;li&gt;Final slice → Commit happens, DOM updated.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ⚡️ 6. Concurrent Rendering
&lt;/h2&gt;

&lt;p&gt;Concurrent rendering builds on incremental rendering by allowing &lt;strong&gt;partial commits&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Commit input immediately&lt;/strong&gt; → user sees instant feedback.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Render list in background&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;If user types again → discard old WIP and restart fresh.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ This makes UI feel even smoother.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⏱️ 7. Timeline Comparison
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Incremental Rendering
&lt;/h3&gt;

</description>
      <category>softwaredevelopment</category>
      <category>web</category>
      <category>webdev</category>
    </item>
    <item>
      <title>🚀 Demystifying React Fiber: A Guide to Incremental &amp; Concurrent Rendering ⚛️</title>
      <dc:creator>Yogesh Bamanier</dc:creator>
      <pubDate>Wed, 24 Sep 2025 19:18:03 +0000</pubDate>
      <link>https://forem.com/yorgie7/demystifying-react-fiber-advanced-guide-to-wip-commit-phase-concurrent-rendering-5bme</link>
      <guid>https://forem.com/yorgie7/demystifying-react-fiber-advanced-guide-to-wip-commit-phase-concurrent-rendering-5bme</guid>
      <description>&lt;h2&gt;
  
  
  An in-depth guide on React Fiber, exploring WIP, commit phase, incremental and concurrent rendering, multiple WIP trees, and hooks management.
&lt;/h2&gt;




&lt;h2&gt;
  
  
  🌟 Introduction
&lt;/h2&gt;

&lt;p&gt;When I started digging into &lt;strong&gt;React Fiber&lt;/strong&gt;, I had endless questions swirling in my head:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;When is the WIP (work-in-progress) Fiber created?&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;If a child’s state updates, why does React rebuild from the parent?&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;What happens if half of the work is done and React decides to pause?&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Can multiple WIP trees exist at the same time?&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This article is a &lt;strong&gt;knowledge base + story&lt;/strong&gt; of my journey understanding Fiber. I’ll explain concepts in sequence while weaving in the exact questions that drove my curiosity.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧵 The First Spark — When is Fiber Created?
&lt;/h2&gt;

&lt;p&gt;When you run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&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;createRoot&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;react-dom/client&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;createRoot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;container&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;App&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;React creates a &lt;strong&gt;Root Fiber&lt;/strong&gt; (&lt;code&gt;HostRootFiber&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;From this root, React builds the &lt;strong&gt;current Fiber tree&lt;/strong&gt; (the DOM your app shows).&lt;/li&gt;
&lt;li&gt;At the same time, whenever a render is triggered, React starts building a &lt;strong&gt;WIP Fiber tree&lt;/strong&gt; (the potential next UI).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Only &lt;strong&gt;one root Fiber&lt;/strong&gt; exists, but it can have &lt;strong&gt;two children&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;current&lt;/code&gt; → what’s painted on screen.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;workInProgress&lt;/code&gt; → being built in memory for the next paint.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔄 The WIP Story
&lt;/h2&gt;

&lt;h3&gt;
  
  
  My Question:
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Does React build WIP after each commit? If yes, how does it know about pending work?&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Answer:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;After every &lt;strong&gt;commit&lt;/strong&gt;, the WIP becomes the new &lt;strong&gt;current&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If updates are queued while rendering, React either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reuses partial WIP work&lt;/strong&gt; (resume rendering).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Discards half-done WIP&lt;/strong&gt; and starts a fresh one for better responsiveness.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;💡 Even if React discards a WIP, your updates aren’t lost — they live in the &lt;strong&gt;update queue of the current Fiber&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⏸️ Pausing, Resuming, and Discarding
&lt;/h2&gt;

&lt;p&gt;React Fiber was built to support &lt;strong&gt;interruptible rendering&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If work takes too long, React will &lt;strong&gt;yield&lt;/strong&gt; (pause) to let the browser paint.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;On the next frame, React can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Resume the same WIP&lt;/strong&gt; (continue where it left).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Discard WIP&lt;/strong&gt; and rebuild from current (if higher-priority update arrived).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;📌 Example:&lt;br&gt;
If you typed into &lt;code&gt;&amp;lt;input /&amp;gt;&lt;/code&gt;, React might &lt;strong&gt;throw away half-done WIP&lt;/strong&gt; and rebuild quickly so your keystroke feels instant.&lt;/p&gt;


&lt;h2&gt;
  
  
  🌳 Parent–Child Fiber Reconciliation
&lt;/h2&gt;
&lt;h3&gt;
  
  
  My Question:
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;If only &lt;code&gt;child1&lt;/code&gt; state changes, why does React traverse from root → parent → child1 → child2?&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Answer:
&lt;/h3&gt;

&lt;p&gt;Because reconciliation always starts from the &lt;strong&gt;parent of the updated Fiber&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Parent’s WIP Fiber is rebuilt.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Children are visited to decide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reuse existing Fiber (&lt;code&gt;alternate&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Or create new WIP Fiber (if props/state changed).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 This is why even siblings (like &lt;code&gt;child2&lt;/code&gt;) may be traversed, though not always rebuilt.&lt;/p&gt;


&lt;h2&gt;
  
  
  ⚡ Commit Phase — Expanded View
&lt;/h2&gt;

&lt;p&gt;I initially thought &lt;em&gt;commit = “DOM changes are applied”&lt;/em&gt;, but it’s much richer.&lt;/p&gt;

&lt;p&gt;Commit has &lt;strong&gt;three steps&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Before Mutation (snapshot phase)&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;getSnapshotBeforeUpdate&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;React prepares, e.g., measuring scroll position.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Mutation Phase&lt;/strong&gt; (sync, cannot be interrupted 🚨)&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;DOM nodes are created/updated/removed.&lt;/li&gt;
&lt;li&gt;Example: inserting all ready child DOM nodes in a single batch for performance.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Layout Phase (effects)&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Runs lifecycle hooks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;componentDidMount&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;componentDidUpdate&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Runs passive effects scheduling.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Only after this, the &lt;strong&gt;browser paints&lt;/strong&gt; with the new UI.&lt;/p&gt;


&lt;h2&gt;
  
  
  🎭 Multiple WIP Trees
&lt;/h2&gt;

&lt;p&gt;Here’s the part that really blew my mind:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React &lt;strong&gt;can prepare multiple versions of the UI simultaneously&lt;/strong&gt;, but &lt;strong&gt;only in between commit waves&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;At any given moment:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;current&lt;/code&gt; → the UI you see.&lt;/li&gt;
&lt;li&gt;One or more &lt;strong&gt;WIP candidates&lt;/strong&gt; in memory.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;⚖️ React chooses the &lt;strong&gt;winning WIP&lt;/strong&gt; at commit time. Others are &lt;strong&gt;discarded&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;📌 Example Flow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Frame 1: WIP Slice A (30 Fibers). Yield.&lt;/li&gt;
&lt;li&gt;Frame 2: Higher-priority update arrives. React may &lt;strong&gt;abandon Slice A&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Frame 3: New WIP tree built, committed, and painted.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So yes — &lt;strong&gt;multiple WIPs can exist between commits&lt;/strong&gt;, but &lt;strong&gt;only one reaches the DOM&lt;/strong&gt;.&lt;/p&gt;


&lt;h2&gt;
  
  
  🧩 Incremental Rendering vs Concurrent Rendering
&lt;/h2&gt;

&lt;p&gt;I used to mix these two. Here’s the difference:&lt;/p&gt;
&lt;h3&gt;
  
  
  Incremental Rendering (Time Slicing)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Breaks a single render into smaller chunks (slices)&lt;/li&gt;
&lt;li&gt;Each slice is executed for a small duration (~5ms-16ms), then yields control to the browser&lt;/li&gt;
&lt;li&gt;Keeps the UI responsive during heavy renders&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&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="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="nc"&gt;HeavyList&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;   // takes long to render
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Sidebar&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;     // light component
    &lt;span class="p"&gt;&amp;lt;/&amp;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;ul&gt;
&lt;li&gt;React renders &lt;code&gt;Sidebar&lt;/code&gt; in the first slice, then starts &lt;code&gt;HeavyList&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;If a user clicks a button during &lt;code&gt;HeavyList&lt;/code&gt; rendering, React can yield to handle input immediately&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Concurrent Rendering
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;React can &lt;strong&gt;prepare multiple WIP trees&lt;/strong&gt; simultaneously for the same root&lt;/li&gt;
&lt;li&gt;Enables high-priority updates to interrupt low-priority work&lt;/li&gt;
&lt;li&gt;WIP trees are in memory; only one is committed to the DOM&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;App&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;SearchBar&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;      // high priority
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Feed&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;           // low priority, heavy list
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;App&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Typing in &lt;code&gt;SearchBar&lt;/code&gt; triggers a high-priority WIP tree&lt;/li&gt;
&lt;li&gt;React may pause &lt;code&gt;Feed&lt;/code&gt; WIP, build &lt;code&gt;SearchBar&lt;/code&gt; update concurrently&lt;/li&gt;
&lt;li&gt;The most appropriate WIP tree commits first&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key Difference:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Incremental = split one render into chunks&lt;/li&gt;
&lt;li&gt;Concurrent = multiple possible renders at the same time, React decides which to commit&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🕒 Timeline Comparison
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Incremental Rendering
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Type "a"
 -&amp;gt; Render Input Fiber
 -&amp;gt; Pause
 -&amp;gt; Render List Fiber (chunked)
 -&amp;gt; Commit everything
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Concurrent Rendering
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Type "a"
 -&amp;gt; Commit Input Fiber immediately
 -&amp;gt; Start List Fiber in background

Type "ab" before List finishes
 -&amp;gt; Discard old List Fiber
 -&amp;gt; Start new List Fiber with "ab"
 -&amp;gt; Commit when ready
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This timeline shows how &lt;strong&gt;incremental rendering&lt;/strong&gt; splits work in one render while &lt;strong&gt;concurrent rendering&lt;/strong&gt; handles multiple WIPs and high-priority interruptions.&lt;/p&gt;




&lt;h2&gt;
  
  
  📖 Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Fiber enables &lt;strong&gt;time-sliced, interruptible rendering&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;WIP is always built in memory; DOM only updates during &lt;strong&gt;commit&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;React may &lt;strong&gt;pause, resume, or discard WIP&lt;/strong&gt; based on priority.&lt;/li&gt;
&lt;li&gt;Multiple WIP trees can exist &lt;strong&gt;between commit waves&lt;/strong&gt;, but only one survives.&lt;/li&gt;
&lt;li&gt;Commit Phase has &lt;strong&gt;3 sub-phases&lt;/strong&gt; (before mutation, mutation, layout).&lt;/li&gt;
&lt;li&gt;Update queues ensure &lt;strong&gt;no user input is lost&lt;/strong&gt;, even if WIP is thrown away.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ✍️ Author
&lt;/h2&gt;

&lt;p&gt;👨‍💻 &lt;em&gt;Yogesh Bamanier&lt;/em&gt;&lt;br&gt;
🔗 &lt;a href="https://www.linkedin.com/in/yogesh-007/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>reactjsdevelopment</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
