<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aditya  pandey on Medium]]></title>
        <description><![CDATA[Stories by Aditya  pandey on Medium]]></description>
        <link>https://medium.com/@captain-adi?source=rss-0c2edd286372------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BUjdSvpmWHTAxWj-XBib2g.gif</url>
            <title>Stories by Aditya  pandey on Medium</title>
            <link>https://medium.com/@captain-adi?source=rss-0c2edd286372------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 14:20:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@captain-adi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ How React Works Under the Hood]]></title>
            <link>https://captain-adi.medium.com/how-react-works-under-the-hood-683ce807d1df?source=rss-0c2edd286372------2</link>
            <guid isPermaLink="false">https://medium.com/p/683ce807d1df</guid>
            <dc:creator><![CDATA[Aditya  pandey]]></dc:creator>
            <pubDate>Sun, 03 Aug 2025 05:34:28 GMT</pubDate>
            <atom:updated>2025-08-03T05:39:20.248Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ikcCqQkRY4mOGNOo" /><figcaption>Photo by <a href="https://unsplash.com/@lautaroandreani?utm_source=medium&amp;utm_medium=referral">Lautaro Andreani</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>When you’re building a React app and make a quick change — like updating a component or modifying state — it feels seamless. The UI updates instantly, no delays, no flickers.</p><p>But have you ever wondered <strong>what’s really happening behind the scenes?</strong> How does React handle updates so efficiently?</p><p>In this post, we’ll break down the internals of React — starting from the <strong>DOM</strong>, understanding the <strong>Virtual DOM</strong>, <strong>Reconciliation</strong>, and finally, diving into <strong>Fiber</strong>, the core of React’s rendering engine.</p><h3>DOM ( Document Object Model ) :</h3><p>The <strong>DOM </strong>is a tree-like representation of your HTML page. Each node represents an element, and every element has a parent-child relationship.</p><p>Here’s a simple example:</p><pre>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;title&gt;This is title&lt;/title&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;h1&gt;This is a header&lt;/h1&gt;<br>    &lt;p&gt;This is a paragraph&lt;/p&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>The DOM tree would look like:</p><pre>&lt;html&gt;<br>├── &lt;head&gt;<br>│   └── &lt;title&gt;<br>├── &lt;body&gt;<br>│   ├── &lt;h1&gt;<br>│   └── &lt;p&gt;</pre><h3>The Problem with Direct DOM Manipulation</h3><p>Modifying the real <strong>DOM</strong> directly with JavaScript (using methods like document.getElementById() or innerHTML) seems simple—but it&#39;s not efficient.</p><p><strong>Here’s why:</strong></p><ul><li><strong>Recalculates layout</strong> after every change.</li><li><strong>Repaints the UI</strong>, even if it’s a minor update.</li><li><strong>Time-consuming and resource-heavy</strong>, especially in large apps.</li></ul><p>React solves this problem beautifully with the <strong>Virtual DOM (VDOM)</strong>.</p><h3>Virtual DOM — A Smarter Approach</h3><p>The <strong>Virtual DOM</strong> is a lightweight copy of the real DOM kept in memory , if we perfrom any changes in the react app ,react does not update DOM directly instead of that React update VDOM.</p><p>Whenever a component changes:</p><ol><li>React creates a <strong>new VDOM tree</strong>.</li><li>Compares it with the <strong>previous version</strong>.</li><li>Calculates <strong>what actually changed</strong>.</li><li>Efficiently updates the real DOM with <strong>minimal changes</strong>.</li></ol><h3>Why Use VDOM?</h3><ul><li>Faster updates.</li><li>Less strain on the browser.</li><li>No unnecessary reflows or repaints.</li><li>Smooth user experience even with frequent changes.</li></ul><h3>Reconciliation — The Diffing Algorithm</h3><p>So how does React know <strong>what changed</strong>?</p><p>Enter <strong>Reconciliation</strong> — a process where React compares the new VDOM with the previous one and determines the <strong>minimum set of changes</strong> needed to update the UI.</p><p>It uses a smart <strong>diffing algorithm</strong> based on heuristics:</p><ul><li>If an element’s type stays the same, React updates its attributes.</li><li>If types differ, it replaces the entire node.</li></ul><p>This keeps things <strong>fast and predictable</strong>.</p><h3>React Fiber — The Heart of Rendering</h3><p>Before React 16, updates were <strong>synchronous</strong>. This meant if your component tree was huge, rendering would block the main thread — and hurt performance.</p><p>To fix this, React introduced a new engine: <strong>Fiber</strong>.</p><h3>What is Fiber?</h3><p><strong>Fiber</strong> is React’s reimplementation of its core algorithm. It breaks rendering into <strong>small units of work</strong> and spreads it across multiple frames, enabling <strong>asynchronous rendering</strong>.</p><h3>Why Fiber Matters</h3><ul><li>Can <strong>pause and resume</strong> rendering.</li><li><strong>Prioritize</strong>s critical updates (like user input) over background work.</li><li>Allows <strong>incremental rendering</strong> — no more freezing UIs!</li><li>Powers features like Suspense, useTransition, and Concurrent Mode.</li></ul><p>Fiber is what allows React to be <strong>responsive</strong>, even with complex UIs and dynamic data.</p><h3>The Full Update Cycle in React</h3><p>Here’s how React handles updates under the hood:</p><ol><li>You trigger a change (state/props update).</li><li>React re-renders the affected component and builds a new Virtual DOM.</li><li>React <strong>diffs</strong> the new VDOM against the old one (Reconciliation).</li><li>React <strong>schedules</strong> and prioritizes updates using <strong>Fiber</strong>.</li><li>React <strong>commits only the changed parts</strong> to the real DOM.</li></ol><p>All of this happens fast — and often in a single animation frame (~16ms).</p><h3>✨ Final Thoughts</h3><p>React makes UI updates look easy — but it’s doing <strong>a lot of work</strong> behind the scenes to keep your app smooth and fast.</p><p>From:</p><ul><li>The <strong>Virtual DOM</strong> that avoids expensive direct DOM updates,</li><li>To <strong>Reconciliation</strong> that compares trees efficiently,</li><li>And <strong>Fiber</strong> that enables responsive, prioritized rendering…</li></ul><p>React’s internal architecture is a masterclass in performance optimization.</p><p>So next time you write a simple setState() or update a component—know that React is doing something truly magical to make it feel effortless.</p><p>🧠 <strong>Did this help you understand React better?</strong><br> Feel free to share this post or leave a comment if you’d like a follow-up on topics like <strong>Concurrent Mode</strong>, <strong>Suspense</strong>, or <strong>React internals</strong>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=683ce807d1df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ How to Send Data from Frontend to Backend Using a Form]]></title>
            <link>https://captain-adi.medium.com/how-to-send-data-from-frontend-to-backend-using-a-form-39413f165e46?source=rss-0c2edd286372------2</link>
            <guid isPermaLink="false">https://medium.com/p/39413f165e46</guid>
            <dc:creator><![CDATA[Aditya  pandey]]></dc:creator>
            <pubDate>Tue, 11 Mar 2025 15:11:03 GMT</pubDate>
            <atom:updated>2025-03-11T15:11:03.216Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, we will explore how to send data from the frontend to the backend using a form. Whether you use the <strong>GET</strong> or <strong>POST</strong> method, understanding how to handle requests is crucial for web development. We will break it down step by step, focusing on implementing a simple form in <strong>React</strong> and connecting it to a <strong>Node.js (Express)</strong> backend.</p><h3>✨ Steps to Follow</h3><h4>📝 1. Create a Form in React</h4><p>a. Send a POST , GET Request to the Backend : in the place of form data you can put your data in my case it is {userName,content }</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*RlOqkn2WfuRjLWYeY9H8yA.png" /></figure><h4>Checking the Request Status :</h4><p>After sending the request, we need to check if it was successful. If response.ok is false, an error is logged and If <strong>anything goes wrong</strong> (e.g., network issue, server down), the catch block logs the error</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*0HP5D7bFtTQ_HCDdqb6A2Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*36Yd10LokkuZTltCle94Fw.png" /></figure><h4>⚙️ 2. Set Up the Backend (Node.js + Express)</h4><p>Now, let’s create a simple backend to handle the form submission.</p><h4>📌 Install Dependencies</h4><pre>npm install express cors</pre><h4>🖥️ <strong>Backend Code (server.js)</strong></h4><pre>import express from &quot;express&quot;;<br>import cors from &quot;cors&quot;;<br><br>const app = express();<br>app.use(cors()); // Enable CORS for frontend requests<br>app.use(express.json()); // Middleware to parse JSON data<br><br><br><br>const PORT = 5000;<br>app.listen(PORT, () =&gt; console.log(`Server running on port ${PORT}`));<br><br>app.post(&quot;/api/posts&quot;, (req, res) =&gt; {<br>  const { username, content, id } = req.body;<br>  posts.push({ username, content, id });<br>  console.log(posts);<br>  res.send(posts);<br>});</pre><h3>📢 <strong>Breaking Down the Backend Code</strong></h3><p>✅ <strong>Setting up a POST route:</strong></p><pre>app.post(&quot;/api/posts&quot;, (req, res) =&gt; {</pre><ul><li>This line sets up a <strong>POST route</strong> at &quot;/api/posts&quot;.</li><li>When a <strong>POST request</strong> is made to this route, the function inside runs.</li></ul><h4>2. Extracting Data from the Request Body</h4><pre>const { username, content, id } = req.body;</pre><ul><li>req.body contains the data sent by the frontend.</li><li>The { username, content, id } syntax extracts these values from req.body.</li></ul><p>📌 <strong>Example Request from Frontend:</strong><br> When the frontend sends a POST request with JSON data:</p><pre>{<br>  &quot;username&quot;: &quot;Aditya&quot;,<br>  &quot;content&quot;: &quot;Hello, this is my first post!&quot;,<br>  &quot;id&quot;: 1<br>}</pre><p>✅ <strong>Extracting Data from the Request Body:</strong></p><ul><li>username = &quot;Aditya&quot;</li><li>content = &quot;Hello, this is my first post!&quot;</li><li>id = 1</li></ul><h4>3. Storing the Data</h4><pre>posts.push({ username, content, id });</pre><ul><li>This adds the new post { username, content, id } to the posts array.</li><li><strong>Important: </strong><strong>posts must be defined somewhere before this route (e.g., </strong><strong>let posts = []; at the top of the file).</strong></li></ul><h4>4. Sending the Response to the Frontend :</h4><pre>res.send(posts);</pre><ul><li>Sends the <strong>updated</strong> posts array back to the frontend.</li><li>The frontend receives the full list of posts, including the newly added one.</li></ul><h3>Final Thoughts</h3><p>✔️ This setup allows your frontend <strong>React form</strong> to send data to the backend using <strong>fetch()</strong>.<br> ✔️ The backend <strong>receives, validates, and stores</strong> the data temporarily in an array.<br> ✔️ However, this data <strong>disappears when the server restarts</strong>.</p><p>🔹 <strong>Next Steps:</strong> To store data permanently, <strong>use a database</strong> like <strong>MongoDB or PostgreSQL</strong> instead of an array.</p><h3>🙌 Thank You for Reading!</h3><p>I hope this guide helped you understand <strong>how to send data from the frontend to the backend using a form</strong>. Whether you’re working on a simple project or building a full-stack application, mastering these basics is essential!</p><p>If you have any <strong>questions or feedback</strong>, feel free to drop a comment. Stay curious, keep coding, and happy learning! 🚀💻✨</p><p>See you in the next blog! 😃👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39413f165e46" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[️Setup React Router]]></title>
            <link>https://captain-adi.medium.com/%EF%B8%8Fsetup-react-router-7e240c5b1264?source=rss-0c2edd286372------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e240c5b1264</guid>
            <dc:creator><![CDATA[Aditya  pandey]]></dc:creator>
            <pubDate>Mon, 26 Aug 2024 17:56:51 GMT</pubDate>
            <atom:updated>2025-04-03T08:54:17.920Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_sF2alP5hVXpfoNZ" /><figcaption>Photo by <a href="https://unsplash.com/@gamell?utm_source=medium&amp;utm_medium=referral">Joan Gamell</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This blog post is about integrating React Router into a React.js application. We’ll walk through the steps needed to set up routing in a React project, ensuring that different components are displayed based on the URL path. This tutorial assumes that you have some basic knowledge of React. Let’s get started!🚀</p><p>🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴<br><strong>GitHub Repositories For Code :— </strong><a href="https://github.com/captain-adi/React-Routing"><strong><em>Github-Repo</em></strong></a><strong><br>Project Using React Router :-<em> </em></strong><a href="https://react-routing-lake.vercel.app/"><strong><em>Project</em></strong></a></p><h3>📦 Installing React Router</h3><p>First, you’ll need to install React Router. React Router is a library that allows you to handle routing in a React application. It’s particularly useful for creating single-page applications (SPAs), where you need to show different components or pages based on the URL.🌐</p><p>You can install React Router by running the following command in your project’s root directory:</p><pre><br>npm install react-router-dom</pre><h3>🔧 <strong>Setting Up the Router in </strong><strong>main.jsx</strong></h3><p>After installing the library, the next step is to configure the router in your main.jsx file. We&#39;ll use RouterProvider to provide the routing configuration to the entire application.⚙️</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*KySOFNfYEzPIo0975jW_wA.png" /></figure><p>In this example, we define an array of route objects. Each object contains:</p><ul><li><strong>path</strong>: The URL path where you want to navigate 🛣️</li><li><strong>element</strong>: The component that should be displayed when the path is matched.🧩</li><li><strong>children</strong>: Nested routes that will be rendered inside the parent route’s component (more on this in the next section).🌱</li></ul><h3>Creating a Layout Page</h3><p>Often in web applications, you have components like a navbar or footer that should be displayed on every page. To avoid repeating these components in every route, you can create a layout page. This layout page will contain the common components and an Outlet where the child components will be rendered based on the route.🔄 For example in main.jsx , &lt;App/&gt; have children &lt;Hero/&gt; , &lt;Form/&gt; and &lt;About/&gt; thsee components show in place of &lt;Outlet/&gt;</p><p>Here’s an example layout using Outlet:<br>👉 <strong>Note</strong>: In my case, I use App.jsx as a layout page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*oFcTX1S_oX1rDsInz9ctmQ.png" /></figure><p>In this setup, NavBar and Footer are always displayed, while the Outlet component dynamically renders the component that matches the current path.</p><h3>🔴IMPORTANT PART</h3><p>Replace these things <br>&lt;Link&gt; tag insted of &lt;a&gt; tag<br>“to” attribute insted of “href” attribute</p><p><strong>orignal :<br></strong>&lt;a href=”/about”&gt;About&lt;/a&gt;<br><strong>Updated:<br></strong>&lt;Link to=”/about”&gt;About&lt;/Link&gt;</p><h3>📝<strong>Summary</strong></h3><p>In this blog , i covered the basics of setting up routing in a React application using React Router. i installed the react-router-dom package, set up routing in main.jsx, created a router configuration with paths and components, and designed a layout page to manage common components like the navbar and footer. With this setup, you can efficiently manage navigation in your React app and ensure that different components are rendered based on the URL.✅</p><p>This is just the beginning. React Router offers many more features like route parameters, nested routes, and route guards, which you can explore as you become more comfortable with the basics.✨</p><p>If you have any questions or run into issues while implementing these steps, feel free to ask in the comments below! 💬</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e240c5b1264" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>