<?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 zehan khan on Medium]]></title>
        <description><![CDATA[Stories by zehan khan on Medium]]></description>
        <link>https://medium.com/@zehan9211?source=rss-4c626c29975f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rcRtyT9pFGrdToKcwwM8_Q.jpeg</url>
            <title>Stories by zehan khan on Medium</title>
            <link>https://medium.com/@zehan9211?source=rss-4c626c29975f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 04:22:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zehan9211/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[Why Mongoose Crashes in Bun (And How to Fix the v8.startupSnapshot Bug)]]></title>
            <link>https://medium.com/@zehan9211/why-mongoose-crashes-in-bun-and-how-to-fix-the-v8-startupsnapshot-bug-d8eb5e5ef385?source=rss-4c626c29975f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8eb5e5ef385</guid>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[mongoose]]></category>
            <category><![CDATA[bunjs]]></category>
            <category><![CDATA[buns]]></category>
            <dc:creator><![CDATA[zehan khan]]></dc:creator>
            <pubDate>Wed, 24 Jun 2026 22:38:49 GMT</pubDate>
            <atom:updated>2026-06-24T22:38:49.250Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O-Y_TT9IANC2Unl61V8byQ.png" /></figure><p>If you recently tried pairing Bun with a newer version of Mongoose (v8 or v9), your server probably died immediately on startup with this exact stack trace:</p><pre>NotImplementedError: node:v8 isBuildingSnapshot is not yet implemented in Bun.<br>code: &quot;ERR_NOT_IMPLEMENTED&quot;<br>at &lt;anonymous&gt; (…/node_modules/bson/lib/bson.cjs:2610:30)</pre><p>Your code isn’t broken. The problem actually comes from a deep dependency collision involving Bun’s internal polyfills.</p><h3><strong>Why it happens</strong></h3><p>Mongoose relies on the official MongoDB Node.js driver, which uses a library called `bson` for data serialization. Starting in version 6.8.0, the `bson` package added a minor performance check that runs the second the module is loaded: it calls `v8.startupSnapshot.isBuildingSnapshot()`.</p><p>Bun tries to be a seamless drop-in replacement for Node.js by polyfilling core modules like `node:v8`. The catch? They haven’t finished building the `startupSnapshot` feature yet. Instead of gracefully returning `false`, Bun throws a hard `ERR_NOT_IMPLEMENTED` error.</p><p>Because of how module resolution works, the split second you import Mongoose, that BSON file gets evaluated, hits the unimplemented Bun polyfill, and brings down your entire application.</p><h3><strong>The trap: Inline patching</strong></h3><p>A lot of developers try to hack their way around this by mocking the function right at the top of their entry file:</p><pre>// ❌ This doesn’t work in ES Modules!<br>import v8 from &#39;v8&#39;;<br>v8.startupSnapshot.isBuildingSnapshot = () =&gt; false;<br>import mongoose from &#39;mongoose&#39;; // ← Still crashes</pre><p>This fails because ES Modules hoist imports. The JavaScript engine parses your file, finds the `import mongoose` statement, and evaluates that entire dependency tree long before your inline `v8.startupSnapshot` patch ever executes. Mongoose still crashes because the patch was too late.</p><h3><strong>The actual fix: Bun’s ` — preload` flag</strong></h3><p>To beat the module loader, you have to run your patch globally before the application even boots. Bun has a native ` — preload` argument designed exactly for this.</p><p>First, create a dedicated patch file. We need to use `Object.defineProperty` here to safely bypass any internal getters Bun might have set up on that module.</p><pre>// src/patch.ts<br>if (globalThis.process &amp;&amp; globalThis.process.getBuiltinModule) {<br>  try {<br>    const v8 = globalThis.process.getBuiltinModule(&#39;v8&#39;);<br>    if (v8) {<br>      Object.defineProperty(v8, &#39;startupSnapshot&#39;, {<br>        value: {<br>          isBuildingSnapshot: () =&gt; false<br>        },<br>        configurable: true,<br>        writable: true<br>      });<br>     }<br>  } catch (e) {<br>  // Ignore errors in older environments<br>  }<br>}</pre><p>Next, tell Bun to load this file before doing anything else.</p><p>If you run your code via `package.json`, update your start script:</p><pre>{<br>  &quot;scripts&quot;: {<br>    &quot;start&quot;: &quot;bun - preload ./src/patch.ts dist/index.js&quot;<br>  }<br>}</pre><p>If you use `nodemon` for local development, update your config:</p><pre>{<br>  &quot;exec&quot;: &quot;bun - preload ./src/patch.ts src/index.ts&quot;<br>}</pre><p>That’s it. Bun now evaluates `patch.ts` in complete isolation. When it finally moves on to your actual application code, the `v8` module is already safely mocked. Mongoose loads cleanly, and your server boots up without the crash.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8eb5e5ef385" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up a Rails Application with Devise Authentication]]></title>
            <link>https://medium.com/@zehan9211/setting-up-a-rails-application-with-devise-authentication-07e2aabba3ac?source=rss-4c626c29975f------2</link>
            <guid isPermaLink="false">https://medium.com/p/07e2aabba3ac</guid>
            <category><![CDATA[ruby-on-rails-development]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[rails]]></category>
            <dc:creator><![CDATA[zehan khan]]></dc:creator>
            <pubDate>Wed, 23 Oct 2024 23:41:41 GMT</pubDate>
            <atom:updated>2024-10-23T23:41:41.896Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*GXfM-lI6CHRHVPfBhLLUbQ.png" /></figure><p>In this guide, we’ll walk through creating a Rails application with PostgreSQL as the database and integrating user authentication using the Devise gem. Follow these steps carefully to build a fully functional authentication system in your Rails app.</p><h3>Step 1: Create a New Rails App</h3><p>Start by creating a new Rails application without the default test framework and with PostgreSQL as the database.</p><pre>rails new application_name -T -d=postgresql</pre><p>Replace application_name with your desired application name.</p><h3>Step 2: Configure Database</h3><p>After creating the application, navigate into the project folder:</p><pre>cd application_name</pre><p>Open the config/database.yml file and update it with your PostgreSQL credentials. Here’s a sample configuration:</p><pre>default: &amp;default<br>  adapter: postgresql<br>  encoding: unicode<br>  pool: &lt;%= ENV.fetch(&quot;RAILS_MAX_THREADS&quot;) { 5 } %&gt;<br>  username: postgres<br>  password: your_password<br>  host: localhost<br><br>development:<br>  &lt;&lt;: *default<br>  database: application_name<br><br>test:<br>  &lt;&lt;: *default<br>  database: application_name_test<br><br>production:<br>  &lt;&lt;: *default<br>  database: application_name_production</pre><p>Once the database credentials are set, create the database:</p><pre>rails db:create</pre><h3>Step 3: Add the Devise Gem</h3><p>Devise provides an easy way to implement authentication. Add it to your project by running:</p><pre>bundle add devise</pre><p>After adding the gem, install Devise by running:</p><pre>rails generate devise:install</pre><h3>Step 4: Complete Devise Setup</h3><p>After installation, follow these essential steps to complete the setup:</p><h4>1. Set Default URL Options</h4><p>Open config/environments/development.rb and add the following line to configure the default URL options for your development environment:</p><pre>config.action_mailer.default_url_options = { host: &#39;localhost&#39;, port: 3000 }</pre><p>For production, you’ll need to specify the actual host.</p><h4>2. Define a Root Route</h4><p>In config/routes.rb, define a root route to prevent routing errors:</p><p>If you don’t have a HomeController, create one:</p><pre>rails generate controller Home index</pre><p><strong>3. Add Flash Messages</strong><br>To display Devise alerts and notices, add the following lines to app/views/layouts/application.html.erb inside the &lt;body&gt; tag:</p><pre>&lt;p class=&quot;notice&quot;&gt;&lt;%= notice %&gt;&lt;/p&gt;<br>&lt;p class=&quot;alert&quot;&gt;&lt;%= alert %&gt;&lt;/p&gt;</pre><p><strong>4. (Optional) Copy Devise Views for Customization</strong><br>If you want to customize Devise’s views, generate them with:</p><pre>rails generate devise:views</pre><h3>Step 5: Generate Devise User Model</h3><p>Use the following command to generate a User model with Devise:</p><pre>rails generate devise User</pre><p>This command will create a migration for the User model with the necessary Devise fields.</p><h3>Step 6: Migrate the Database</h3><p>Run the migration to update the database with the new User table:</p><pre>rails db:migrate</pre><h3>Step 7: Start the Rails Server</h3><p>Finally, run the Rails server to start your application:</p><pre>rails s</pre><p>You can now access your application at <a href="http://localhost:3000.">http://localhost:3000.</a></p><p><a href="https://github.com/zehan12/ruby_on_rails_devise_authentication">GitHub - zehan12/ruby_on_rails_devise_authentication</a></p><h3>Conclusion</h3><p>With these steps, you’ve successfully created a Rails application with PostgreSQL and integrated Devise for user authentication. You can now further customize your user model or devise views as needed for your application’s requirements.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=07e2aabba3ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering SOLID Principles in JavaScript]]></title>
            <link>https://medium.com/@zehan9211/mastering-solid-principles-in-javascript-5380c78f0500?source=rss-4c626c29975f------2</link>
            <guid isPermaLink="false">https://medium.com/p/5380c78f0500</guid>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[js]]></category>
            <category><![CDATA[solid]]></category>
            <category><![CDATA[principles-of-design]]></category>
            <dc:creator><![CDATA[zehan khan]]></dc:creator>
            <pubDate>Fri, 18 Oct 2024 20:41:48 GMT</pubDate>
            <atom:updated>2024-10-18T20:41:48.207Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S0frUwylj_4kXHtT5FD0yg.png" /><figcaption>*All illustrations in this article are by <a href="https://medium.com/u/139892399b5e?source=post_page-----b34ce2f1e898--------------------------------">Ugonna Thelma</a></figcaption></figure><p>The <strong>SOLID principles</strong> are five design principles intended to make software designs more understandable, flexible, and maintainable. They are essential for writing clean code that is easy to extend and adapt without introducing bugs.</p><p>Here’s an overview of each <strong>SOLID</strong> principle with clear explanations:</p><h3>S — Single Responsibility Principle (SRP)</h3><p>A class should have one and only one reason to change. It should only do one job.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O6P1efVywJovPbsDZynD-A.png" /></figure><h4>Bad Example</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RGOWnCQUPuJS8TawSszEkw.png" /></figure><p><strong>Issue</strong>:<br>The User class does two things: saving to the database and sending emails. This violates the SRP principle.</p><h4>SRP Solution</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2516910f1eb52f1032555a0ea65e49c5/href">https://medium.com/media/2516910f1eb52f1032555a0ea65e49c5/href</a></iframe><p><strong>Why it’s Better</strong>:<br>Each class has a single responsibility, making it easier to maintain and extend.</p><h3>O — Open/Closed Principle (OCP)</h3><p>Classes should be open for extension, but closed for modification. You should be able to add new functionality without changing existing code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UNSD-lPPob8C49dBuiaA4A.png" /></figure><h4>Bad Example</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N76lfGnTDFH8_HBIw0PRNQ.png" /></figure><p><strong>Issue</strong>:<br>Every time you add a new payment method (like Apple Pay), you must modify the Payment class, violating the OCP principle.</p><h4>OCP Solution</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c95a1408adbfd3e87cf7aa846120683/href">https://medium.com/media/0c95a1408adbfd3e87cf7aa846120683/href</a></iframe><p><strong>Why it’s Better</strong>:<br>You can extend the system by adding new payment strategies (e.g., ApplePayPayment) without changing the existing Payment class.</p><h3>L — Liskov Substitution Principle (LSP)</h3><p>Objects of a superclass should be replaceable with objects of a subclass without breaking the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Bv5xFfreNw0Nosw5G4kfQ.png" /></figure><h4>Bad Example</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XDRieXOk99WDB9o_KvYTkg.png" /></figure><p><strong>Issue</strong>:<br>Using PushNotification in place of Notification breaks the system, as it behaves differently by requiring a token.</p><h4>LSP Solution</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e2d19b9b2a35b976a15c30dd30e1293d/href">https://medium.com/media/e2d19b9b2a35b976a15c30dd30e1293d/href</a></iframe><p><strong>Why it’s Better</strong>:<br>PushNotification no longer breaks the LSP by defining its own specific method (sendWithToken). It follows expected behavior without modifying the parent contract.</p><h3>I — Interface Segregation Principle (ISP)</h3><p>Clients should not be forced to depend on methods they do not use. In simpler terms, break down large interfaces into smaller, more specific ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HvhU61a7YqyutZy9TTxX7g.png" /></figure><h4>Bad Example</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-tGA27RLt7BfKfqy7I_Vcg.png" /></figure><p><strong>Issue</strong>:<br>Riders shouldn’t be forced to implement irrelevant methods like payment processing and customer rating.</p><h4>ISP Solution</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4518031b0fb5c6502b693df8b2f4a30c/href">https://medium.com/media/4518031b0fb5c6502b693df8b2f4a30c/href</a></iframe><p><strong>Why it’s Better</strong>:<br>Each service now implements only the methods it needs, ensuring that classes are not forced to depend on unnecessary interfaces.</p><h3>D — Dependency Inversion Principle (DIP)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6IWpB6JTLMJnXsymbY_Vcw.png" /></figure><h4>Bad Example</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zDYqOKvOaia-CujGdUMWhQ.png" /></figure><p><strong>Issue</strong>:<br>The Notification class is tightly coupled with EmailService. If we want to add SMS notifications, we need to modify the Notification class.</p><h4>DIP Solution</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/161acecfbf093e1a3958ae3302d023f1/href">https://medium.com/media/161acecfbf093e1a3958ae3302d023f1/href</a></iframe><p><strong>Why it’s Better</strong>:<br>The Notification class now depends on an abstraction (any service with a send method) rather than a specific implementation. This makes it easy to swap notification channels without modifying existing code.</p><h3>Conclusion:</h3><p>By applying these real-world examples, you can better understand how the <strong>SOLID principles</strong> enhance code quality. They help create scalable, maintainable, and flexible software systems, allowing for easy future growth without breaking existing functionality.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5380c78f0500" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 3 :  Arithmetic Operators in Ruby]]></title>
            <link>https://medium.com/@zehan9211/day-3-arithmetic-operators-in-ruby-78a204fec7d9?source=rss-4c626c29975f------2</link>
            <guid isPermaLink="false">https://medium.com/p/78a204fec7d9</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails-development]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[zehan khan]]></dc:creator>
            <pubDate>Sat, 12 Oct 2024 08:17:35 GMT</pubDate>
            <atom:updated>2024-10-12T08:17:35.913Z</atom:updated>
            <content:encoded><![CDATA[<h3>Day 3 : Arithmetic Operators in Ruby</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hmfIj9O1uIEdFig7qX8cyA.png" /></figure><p>In Ruby, arithmetic operators are actually used to perform simpler arithmetic such as addition, subtraction, multiplication etc. Ruby has a good number of operators with numbers the operators supports is integer and float.</p><h4>1. Addition (+)</h4><ul><li>Adds two numbers together.</li><li>Example:</li></ul><pre>a = 5 + 3  # Result: 8</pre><h4>2. Subtraction (-)</h4><ul><li>Subtracts one number from another.</li><li>Example:</li></ul><pre>b = 10 - 4  # Result: 6</pre><h4>3. Multiplication (*)</h4><ul><li>Multiplies two numbers.</li><li>Example:</li></ul><pre>c = 6 * 7  # Result: 42</pre><h4>4. Division (/)</h4><ul><li>Divides one number by another. If both numbers are integers, the result will also be an integer (the fractional part is discarded). To get a float result, at least one operand should be a float.</li><li>Example:</li></ul><pre>d = 8 / 2  # Result: 4 (integer division) <br>e = 8.0 / 2  # Result: 4.0 (float division)</pre><h4>5. Modulus (%)</h4><ul><li>Returns the remainder of the division.</li><li>Example:</li></ul><pre>f = 10 % 3  # Result: 1 (remainder of 10 divided by 3)</pre><h4>6. Exponentiation (**)</h4><ul><li>Raises one number to the power of another.</li><li>Example:</li></ul><pre>g = 2 ** 3  # Result: 8 (2 raised to the power of 3)</pre><h3>Special Considerations:</h3><ul><li><strong>Order of Operations</strong>: Ruby follows the standard mathematical order of operations (PEMDAS: Parentheses, Exponents, Multiplication, Division, Addition, Subtraction).</li><li>Example:</li></ul><pre>result = 2 + 3 * 4  # Result: 14 (Multiplication before addition) <br>result = (2 + 3) * 4  # Result: 20 (Parentheses change the order)</pre><ul><li><strong>Division Behavior</strong>: In Ruby 2.4 and later, integer division produces an integer result, while division involving at least one float produces a float.</li><li>Example:</li></ul><pre>7 / 2    # Result: 3 (integer division) <br>7.0 / 2  # Result: 3.5 (float division)</pre><h3>Arithmetic with Variables</h3><p>Arithmetic operators can also be used with variables. For example:</p><pre>x = 10<br>y = 5<br>z = x + y  # Result: 15</pre><h3>Compound Assignment Operators</h3><p>Ruby also supports compound assignment operators for arithmetic operations:</p><ul><li>+= : Adds the right-hand operand to the left-hand operand and assigns the result to the left-hand operand.</li><li>-= : Subtracts the right-hand operand from the left-hand operand and assigns the result.</li><li>*= : Multiplies the left-hand operand by the right-hand operand and assigns the result.</li><li>/= : Divides the left-hand operand by the right-hand operand and assigns the result.</li></ul><p>Example:</p><pre>x = 10<br>x += 5  # x is now 15<br>x -= 3  # x is now 12</pre><h3>Conclusion</h3><p>Ruby provides all the standard arithmetic operators, which can be applied to both integers and floats. Understanding how these operators behave, especially in terms of division and operator precedence, is essential for performing accurate mathematical computations in Ruby.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78a204fec7d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Resolve “You Don’t Have Write Permissions for /usr/local/bin” Error When Creating a Rails…]]></title>
            <link>https://medium.com/@zehan9211/how-to-resolve-you-dont-have-write-permissions-for-usr-local-bin-error-when-creating-a-rails-f7d3f154b116?source=rss-4c626c29975f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7d3f154b116</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[rails]]></category>
            <dc:creator><![CDATA[zehan khan]]></dc:creator>
            <pubDate>Tue, 24 Sep 2024 19:56:25 GMT</pubDate>
            <atom:updated>2024-09-24T19:56:25.945Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Resolve “You Don’t Have Write Permissions for /usr/local/bin” Error When Creating a Rails App</h3><p>When setting up a new Rails application and running bundle install, you might encounter the following error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QLeH6qPp9ZarP7YijIVMCQ.png" /></figure><p>This error occurs because the current user does not have the necessary permissions to write to the /usr/local/bin directory, which is where Bundler attempts to install executable files.</p><h3>Step-by-Step Solution: Change Directory Ownership with chown</h3><p>The simplest way to resolve this issue is to change the ownership of the /usr/local/bin directory to your current user. Here’s how:</p><ol><li><strong>Open Terminal</strong>: Start your terminal or command prompt.</li><li><strong>Check Current Ownership</strong>: Before making any changes, you can verify the current ownership with:</li></ol><pre>ls -ld /usr/local/bin</pre><p><strong>3. Change Ownership to Your User</strong>: Run the following command to change the ownership of the directory:</p><pre>sudo chown -R $USER /usr/local/bin</pre><ul><li>sudo: Runs the command with superuser privileges.</li><li>chown -R: Changes ownership recursively for the directory and all its contents.</li><li>$USER: Represents your current logged-in username.</li></ul><p><strong>4. Re-run </strong><strong>bundle install</strong>:</p><pre>bundle install</pre><h3>Important Notes</h3><ul><li><strong>Security Considerations</strong>: Changing ownership of system directories can impact security. Only perform this on your local or development machine, not on shared or production environments.</li><li><strong>Alternative Approach</strong>: If altering permissions is not suitable, you can install gems locally using bundle install --path vendor/bundle.</li></ul><h3>Conclusion</h3><p>By changing the ownership of /usr/local/bin, you can resolve permission errors quickly and proceed with setting up your Rails application without further interruptions. Remember to be cautious of where and when you make permission changes to maintain a secure environment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7d3f154b116" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 2 — Ruby Data Types: What You Need to Know!]]></title>
            <link>https://medium.com/@zehan9211/day-2-ruby-data-types-what-you-need-to-know-d0c96b77c4a0?source=rss-4c626c29975f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0c96b77c4a0</guid>
            <category><![CDATA[ruby-on-rails-development]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[data-type]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[zehan khan]]></dc:creator>
            <pubDate>Sun, 22 Sep 2024 09:02:04 GMT</pubDate>
            <atom:updated>2024-09-22T09:30:13.683Z</atom:updated>
            <content:encoded><![CDATA[<h3>Day 2: Ruby Data Types - What You Need to Know!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*-Ow15Ara4PhNkunRslGZZA.png" /></figure><h3>1. Basic Data Types</h3><h3>Numbers</h3><p>Ruby supports two main types of numbers:</p><ul><li><strong>Integer</strong>: Whole numbers, both positive and negative. They are perfect for counting or performing arithmetic operations.</li></ul><pre>age = 25</pre><ul><li><strong>Float</strong>: These are numbers that contain decimal points. They are useful for representing values that require precision, such as prices or measurements.</li></ul><pre>price = 19.99</pre><h3>Strings</h3><p>Strings are sequences of characters enclosed in single (&#39;) or double (&quot;) quotes. In Ruby, strings are mutable, meaning you can modify them after creation. You can concatenate, slice, and manipulate strings in various ways.</p><pre>greeting = &quot;Hello, world!&quot;</pre><h3>Symbols</h3><p>Symbols are lightweight, immutable strings primarily used as identifiers, often in hashes. Unlike strings, symbols are unique, meaning that the same symbol is stored only once in memory, making them more memory-efficient for certain use cases.</p><pre>status = :active</pre><h3>2. Composite Data Types</h3><h3>Arrays</h3><p>Arrays are ordered collections of elements that can hold objects of any type. They are dynamic, allowing you to add or remove elements as needed. Arrays can be indexed and iterated over easily.</p><pre>lang = [&quot;ruby&quot;, &quot;python&quot;,&quot;elixir&quot;]</pre><h3>Hashes</h3><p>Hashes are collections of key-value pairs. They are similar to dictionaries in other languages and are extremely useful for storing related data. You can easily access values using their corresponding keys.</p><pre>person = { name: &quot;Zehan&quot;, age: 25, city: &quot;Banglore&quot; }</pre><h3>Ranges</h3><p>Ranges represent a sequence of values, defined by a starting point and an endpoint. You can create ranges using the .. (inclusive) or ... (exclusive) operators, which can be useful for iteration.</p><pre>range = (1..6)  # Represents 1, 2, 3, 4, 5, 6<br>exclusive_range = (1...10)  # Represents 1, 2, 3, 4, 5, 6, 7, 8, 9</pre><h3>3. Boolean Type</h3><p>Ruby has a built-in Boolean data type, which can hold one of two values: true or false. This data type is essential for conditional statements and logical operations, enabling you to control the flow of your programs.</p><pre>is_login = true</pre><h3>4. Nil Class</h3><p>In Ruby, nil represents the absence of a value or an undefined state. It’s an instance of the NilClass and is commonly used to indicate that a variable does not contain any meaningful value.</p><pre>user = nil</pre><h3>5. Type Checking and Conversion</h3><p>Ruby provides several ways to check data types and convert between them. This flexibility is one of the language’s strengths.</p><h3>5.1. Checking Types</h3><p>You can check an object’s type using the class method or the is_a? method:</p><pre>puts age.class        # Outputs: Integer<br>puts fruits.is_a?(Array)  # Outputs: true</pre><h3>5.2. Type Conversion</h3><p>Ruby allows for both implicit and explicit type conversion. For example, converting a string to an integer is straightforward:</p><pre>string_number = &quot;123&quot;<br>number = string_number.to_i  # Outputs: 123</pre><h3>Conclusion</h3><p>So there you have it, folks! Understanding Ruby’s data types is crucial for writing elegant and effective code. From basic types like integers and strings to composite types like arrays and hashes, Ruby offers a flexible way to manage data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0c96b77c4a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Component Lifecycle Using Hooks]]></title>
            <link>https://medium.com/@zehan9211/react-component-lifecycle-using-hooks-ac5d4a5daab3?source=rss-4c626c29975f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac5d4a5daab3</guid>
            <category><![CDATA[hooks-in-react]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[zehan khan]]></dc:creator>
            <pubDate>Fri, 20 Sep 2024 08:41:10 GMT</pubDate>
            <atom:updated>2024-09-20T08:41:10.434Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yg03srL3AZ11SWMgW-uwkw.png" /></figure><p>In modern React, hooks offer a functional approach to managing component lifecycle, replacing the need for class-based components. Before we dive in, it’s important to understand that every component still has a lifecycle that is divided into three parts: <strong>mounting</strong>, <strong>updating</strong>, and <strong>unmounting</strong>.</p><p>With hooks, we use useEffect() to replicate most lifecycle methods in functional components. Hooks provide a cleaner and more intuitive way to handle these phases without relying on class components.</p><h3>Mounting Phase (With Hooks)</h3><p>In class components, the constructor() and componentDidMount() methods handle mounting, but with hooks, this is done using the useEffect() hook.</p><p>Here’s how to use hooks for mounting:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3d7caaf160fdd2423277bf3de0d352a/href">https://medium.com/media/c3d7caaf160fdd2423277bf3de0d352a/href</a></iframe><p>In the above example:</p><ul><li>useEffect() with an empty dependency array mimics componentDidMount() by running only once after the component is mounted.</li><li>Any code you want to run upon mounting (like API calls) can be placed inside the useEffect().</li><li>If there’s a cleanup action needed when the component is unmounted, we can return a cleanup function from useEffect(), which mimics componentWillUnmount().</li></ul><h3>Updating Phase (With Hooks)</h3><p>In class components, componentDidUpdate() handles updates. In functional components, we use useEffect() with a dependency array to listen for changes and trigger side effects.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/981317442a8b969ee2d40abd0177993c/href">https://medium.com/media/981317442a8b969ee2d40abd0177993c/href</a></iframe><p>In this example:</p><ul><li>The useEffect() listens for changes in count and behaves similarly to componentDidUpdate(). It triggers every time count is updated.</li></ul><h3>Unmounting Phase (With Hooks)</h3><p>To handle cleanup when a component is unmounted (which is similar to componentWillUnmount()), we return a cleanup function from useEffect().</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc610ac08f7088a3c018c9be4747d2ad/href">https://medium.com/media/fc610ac08f7088a3c018c9be4747d2ad/href</a></iframe><p>In this example:</p><ul><li>The useEffect() sets up an event listener for window resizing when the component is mounted, and the cleanup function removes this listener when the component is about to unmount.</li></ul><h3>Redux with Hooks</h3><p>Although not strictly related to lifecycle methods, Redux integrates well with hooks. Instead of using connect() from react-redux, you can use useSelector() and useDispatch() to interact with the Redux store.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f70389c81ba2001cea8e1659d23c4362/href">https://medium.com/media/f70389c81ba2001cea8e1659d23c4362/href</a></iframe><h3>Conclusion</h3><p>Hooks simplify the management of component lifecycle by consolidating lifecycle methods into the useEffect() hook. This functional approach removes the need for class-based components while providing the same functionality.</p><ul><li><strong>Mounting</strong>: Use useEffect() with an empty dependency array to mimic componentDidMount().</li><li><strong>Updating</strong>: Use useEffect() with specific dependencies to mimic componentDidUpdate().</li><li><strong>Unmounting</strong>: Return a cleanup function in useEffect() to mimic componentWillUnmount().</li></ul><p>By using hooks, React’s lifecycle management becomes more intuitive and easier to maintain, making your components more efficient and reducing boilerplate code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac5d4a5daab3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 1: Understanding Ruby’s print, puts, and p]]></title>
            <link>https://medium.com/@zehan9211/day-1-understanding-rubys-print-puts-and-p-4a8a89acb858?source=rss-4c626c29975f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a8a89acb858</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[zehan khan]]></dc:creator>
            <pubDate>Thu, 19 Sep 2024 14:54:37 GMT</pubDate>
            <atom:updated>2024-09-19T14:56:31.366Z</atom:updated>
            <content:encoded><![CDATA[<h4>Exploring the differences between Ruby’s core output methods</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*nnGUgm0qJFpbwjwahvQZdg.png" /></figure><p>In Ruby, print, puts, and p are used to output data, but they behave differently in terms of formatting and how they display output.</p><h4>What is puts?</h4><p>puts prints the given data and automatically adds a newline after each output. This makes it perfect for displaying items on separate lines.</p><p><strong>Example:</strong></p><pre>puts &quot;Hello&quot;<br>puts &quot;World&quot;</pre><p><strong>Output:</strong></p><pre>Hello<br>World</pre><h4>What is print?</h4><p>print outputs data without adding a newline, so consecutive print statements will display on the same line unless you manually insert a newline.</p><p><strong>Example:</strong></p><pre>print &quot;Hello&quot;<br>print &quot;World&quot;</pre><p><strong>Output:</strong></p><pre>HelloWorld</pre><h4>What is p?</h4><p>p is similar to puts, but it outputs the data in a more inspect-friendly way, displaying the data in its literal form (useful for debugging). It also adds a newline after the output.</p><p><strong>Example:</strong></p><pre>p &quot;Hello&quot;<br>p &quot;World&quot;</pre><p><strong>Output:</strong></p><pre>&quot;Hello&quot;<br>&quot;World&quot;</pre><p>With p, the output includes quotes around the strings, showing their actual object representation.</p><h3>Key Differences</h3><ul><li>puts adds a newline after the output but does not show the object’s literal form.</li><li>print does not add a newline, keeping the output on the same line.</li><li>p outputs the literal form of the object and adds a newline.</li></ul><h3>When to Use Them</h3><ul><li>Use puts for clear, line-separated outputs.</li><li>Use print when you want everything on the same line.</li><li>Use p when you want to inspect the exact representation of your objects (especially helpful for debugging).</li></ul><h3>Conclusion</h3><p>puts, print, and p give you different ways to control the format of your output in Ruby. Whether you need newline-separated text, continuous text on the same line, or object inspection for debugging, knowing when to use each method gives you flexibility in how your data is displayed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a8a89acb858" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using displayName in React: Simplifying Debugging and Improving Readability]]></title>
            <link>https://medium.com/@zehan9211/using-displayname-in-react-simplifying-debugging-and-improving-readability-bbe09b58a6fb?source=rss-4c626c29975f------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbe09b58a6fb</guid>
            <dc:creator><![CDATA[zehan khan]]></dc:creator>
            <pubDate>Tue, 10 Sep 2024 15:23:31 GMT</pubDate>
            <atom:updated>2024-09-10T15:29:41.417Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qrttZYKC-XdRfOBYWZH4AQ.png" /></figure><blockquote>When working with React, especially on complex projects, keeping track of components can become tricky, especially during debugging. This is where React’s displayName property comes into play. It allows you to assign a custom name to your component, making it easier to identify in debugging tools and logs.</blockquote><blockquote>In this article, we’ll explore what displayName is, why it&#39;s useful, and how to use it effectively in your React projects.</blockquote><h3>What is displayName?</h3><p>React automatically assigns a name to components based on how they are declared. However, in certain situations (e.g., higher-order components or anonymous functions), these names can be unhelpful or unclear. The displayName property lets you manually set a more descriptive name for your component, which is particularly beneficial when viewing components in tools like React DevTools.</p><h3>Example of a Component Without displayName</h3><pre>const MyComponent = () =&gt; {<br>  return &lt;div&gt;Hello, World!&lt;/div&gt;;<br>};<br><br>export default MyComponent;</pre><p>In this example, React assigns the name MyComponent, so in tools like React DevTools, that name is visible. But what happens when you&#39;re dealing with more complex setups, such as higher-order components? That&#39;s when setting displayName becomes valuable.</p><h3>Why Should You Use displayName?</h3><p>When components are wrapped inside higher-order components (HOCs) or are created anonymously, their names can become generic or uninformative. Using displayName helps in several ways:</p><ul><li><strong>Easier Debugging</strong>: Custom component names show up in DevTools, making it easier to understand the component hierarchy.</li><li><strong>Clearer Error Messages</strong>: When errors occur, having a meaningful name helps you quickly identify which component is involved.</li><li><strong>Better Team Collaboration</strong>: In larger teams, descriptive component names make the codebase easier to navigate.</li></ul><p>Let’s dive into specific scenarios where displayName proves to be helpful.</p><h3>Scenario 1: Higher-Order Components</h3><p>Higher-order components can obscure the name of the wrapped component, making it harder to understand what’s being rendered.</p><pre>const withExtraProps = (Component) =&gt; {<br>  const WrappedComponent = (props) =&gt; {<br>    return &lt;Component {...props} extra=&quot;some value&quot; /&gt;;<br>  };<br><br>WrappedComponent.displayName = `withExtraProps(${Component.displayName || Component.name || &#39;Component&#39;})`;<br>  return WrappedComponent;<br>};<br><br>// Original component<br>const MyComponent = () =&gt; {<br>  return &lt;div&gt;Hello, World!&lt;/div&gt;;<br>};<br><br>// Wrapped component<br>const EnhancedComponent = withExtraProps(MyComponent);<br><br>export default EnhancedComponent;</pre><p>Here, without displayName, the wrapped component might show up as withExtraProps in the DevTools. By manually setting the displayName, it will now appear as withExtraProps(MyComponent), making it clear which component is wrapped.</p><h3>Scenario 2: Anonymous Components</h3><p>React components created with anonymous functions are often labeled as Anonymous, which isn’t helpful when debugging. You can give them a specific name using displayName.</p><pre>const MyAnonymousComponent = () =&gt; {<br>  return &lt;div&gt;Hello from an anonymous component!&lt;/div&gt;;<br>};<br><br>MyAnonymousComponent.displayName = &#39;CustomComponentName&#39;;<br><br>export default MyAnonymousComponent;</pre><p>Now, instead of Anonymous, this component will appear as CustomComponentName in DevTools, providing a clear, identifiable name.</p><h3>How to Use displayName</h3><p>Adding a displayName to your components is simple. You just set it as a static property. Here&#39;s how you can do it for different types of components:</p><h3>1. Functional Components</h3><pre>const MyComponent = () =&gt; {<br>  return &lt;div&gt;Functional Component&lt;/div&gt;;<br>};<br><br>MyComponent.displayName = &#39;MyFunctionalComponent&#39;;<br><br>export default MyComponent;</pre><h3>2. Higher-Order Components</h3><p>In higher-order components, adding displayName can retain both the wrapped component&#39;s name and the HOC&#39;s name, making it much clearer which component is being rendered.</p><pre>const withLogger = (Component) =&gt; {<br>  const WrappedComponent = (props) =&gt; {<br>    console.log(&#39;Component Rendered&#39;);<br>    return &lt;Component {...props} /&gt;;<br>  };<br><br>WrappedComponent.displayName = `withLogger(${Component.displayName || Component.name || &#39;Component&#39;})`;<br>  return WrappedComponent;<br>};</pre><h3>3. Memoized Components</h3><p>When using React.memo for performance optimization, you can lose the original component name. Setting a displayName helps keep things clear.</p><pre>const MyComponent = () =&gt; {<br>  return &lt;div&gt;Memoized Component&lt;/div&gt;;<br>};<br><br>const MemoizedComponent = React.memo(MyComponent);<br>MemoizedComponent.displayName = &#39;MyMemoizedComponent&#39;;<br><br>export default MemoizedComponent;</pre><p>Without displayName, the component would appear with a default or less informative name, but with this setup, it&#39;s easy to track in DevTools.</p><h3>Benefits of Using displayName</h3><p>Several tools and situations benefit from manually setting displayName:</p><ul><li><strong>React DevTools</strong>: It’s easier to navigate the component tree when every component has a clear, recognizable name.</li><li><strong>Error Handling</strong>: If something goes wrong, meaningful component names in error logs make tracking down issues quicker.</li><li><strong>Code Readability</strong>: Other developers on your team (or even your future self) will appreciate clear, human-readable component names.</li></ul><h3>Best Practices for displayName</h3><ul><li><strong>Descriptive Names</strong>: Use names that clearly describe the component’s function or purpose.</li><li><strong>Consistency</strong>: Maintain a naming convention across your project, especially when working with HOCs or memoized components.</li><li><strong>Only When Necessary</strong>: React handles naming most of the time, so only use displayName when it adds clarity or improves debugging.</li></ul><h3>Conclusion</h3><p>While React does a great job of automatically naming most components, there are scenarios where manually setting a displayName can significantly enhance your debugging and development experience. Whether you&#39;re working with higher-order components, memoized components, or anonymous functions, displayName helps maintain clarity in your project, making it easier to debug, maintain, and collaborate on.</p><p>By taking advantage of displayName, you can ensure that your components are more easily identifiable, making your development process smoother and more enjoyable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbe09b58a6fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the Importance of key in React: Creating New Instances with Every Change]]></title>
            <link>https://medium.com/@zehan9211/understanding-the-importance-of-key-in-react-creating-new-instances-with-every-change-d8bb5ed5d532?source=rss-4c626c29975f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8bb5ed5d532</guid>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[zehan khan]]></dc:creator>
            <pubDate>Fri, 06 Sep 2024 13:45:23 GMT</pubDate>
            <atom:updated>2024-09-06T13:52:38.862Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*UeDVCoDkkRyFRLYvxzSv-g.png" /></figure><blockquote><em>When working with lists in React, one concept you’ll often come across is the </em><em>key prop. While it may seem like a simple identifier for elements in a list, it plays a crucial role in React&#39;s ability to manage and update the UI efficiently. But did you know that improper usage of </em><em>key can result in React creating a new instance of a component every time it renders, even when unnecessary? In this article, we&#39;ll dive into how and why this happens.</em></blockquote><h4>What is the key Prop in React?</h4><p>The key prop is used by React to track elements within a list and efficiently update only the parts of the DOM that have changed. Each key should be unique among sibling elements. Without proper keys, React might re-render the entire list, which can lead to performance issues or, in some cases, unpredictable behavior.</p><p>Here’s a simple example of a list without a key:</p><pre>&lt;ul&gt;<br>  {items.map((item) =&gt; (<br>    &lt;li&gt;{item}&lt;/li&gt;<br>  ))}<br>&lt;/ul&gt;</pre><p>In this case, React has no way to uniquely identify each &lt;li&gt;, meaning it can only rely on the index of the array to track them. This works for basic use cases but can lead to bugs and performance hits if the order of the array changes or items are added/removed.</p><h4>Why Using key Creates New Instances</h4><p>When React updates a list, it uses the key to decide whether an item should be updated or if a new item should be created. If you don’t assign a stable, unique key, or if the key changes between renders, React will treat the element as a new instance, effectively throwing away the old instance and replacing it with a fresh one. This can cause unexpected behavior, like resetting form inputs or triggering re-renders of components unnecessarily.</p><p>Let’s see how this happens:</p><pre>&lt;ul&gt;<br>  {items.map((item, index) =&gt; (<br>    &lt;li key={index}&gt;{item}&lt;/li&gt;<br>  ))}<br>&lt;/ul&gt;</pre><p>Here, we’re using the index as the key. While this works in static lists, it’s problematic when the list changes dynamically. If you shuffle the items, remove one, or add new ones, React might confuse the order, leading to new instances being created and older ones removed — even though the data hasn’t significantly changed.</p><p>In contrast, assigning a unique identifier as the key ensures React knows exactly which item to update and which one to leave untouched.</p><pre>&lt;ul&gt;<br>  {items.map((item) =&gt; (<br>    &lt;li key={item.id}&gt;{item.name}&lt;/li&gt;<br>  ))}<br>&lt;/ul&gt;</pre><p>With a stable key like item.id, React now knows that if an item&#39;s position changes in the array, it doesn’t need to recreate the component—it can just update it in its new position.</p><h4>Real-World Example: Forms Losing State</h4><p>One common issue with improper key usage occurs with form elements. Imagine you’re building a list of user input fields, and the user can add or remove items from the list. If the keys are not unique or change unexpectedly, React may recreate the input components, leading to users losing their input data. Here&#39;s an example:</p><pre>{inputs.map((input, index) =&gt; (<br>  &lt;input key={index} value={input.value} /&gt;<br>))}</pre><p>In this case, when a user adds a new input field, all the existing input components might lose their state because React thinks they’re new components due to the shifted indexes. By switching to a more stable key (like an ID), you prevent this issue:</p><pre>{inputs.map((input) =&gt; (<br>  &lt;input key={input.id} value={input.value} /&gt;<br>))}</pre><p>Now, React can efficiently update the DOM without unnecessarily recreating components, ensuring that user inputs remain intact.</p><h4>Why Does React Do This?</h4><p>React’s diffing algorithm, called <em>reconciliation</em>, is responsible for determining which elements have changed, been added, or been removed. The key prop allows React to optimize this process by tracking each element uniquely. If the key is consistent, React knows that it only needs to re-render the components where data has actually changed, rather than recreating all of them from scratch.</p><p>When React sees a new key, it assumes that the corresponding component is a new one, discards the previous component instance, and creates a fresh one. This is great when the data truly changes, but when used incorrectly, it can lead to unnecessary re-renders.</p><h4>Demo Link</h4><p>Check out this React key prop demo to see how changing the key prop creates new component instances.</p><p><a href="https://react-create-new-instance.vercel.app/">Create Next App</a></p><p>Repo Link</p><p><a href="https://github.com/zehan12/react-create-new-instance">GitHub - zehan12/react-create-new-instance</a></p><h4>Conclusion</h4><p>Using the key prop in React may seem straightforward, but it has a profound impact on performance and behavior. Assigning a stable and unique key helps React efficiently update the DOM, avoid creating new component instances unnecessarily, and prevent bugs like losing input state in forms. Always ensure that your key values remain consistent across renders to avoid these pitfalls and keep your React app performing smoothly.</p><p>Next time you build a dynamic list in React, remember: a well-chosen key keeps your app fast, stable, and predictable!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8bb5ed5d532" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>