<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Keertivaas S</title>
    <description>The latest articles on DEV Community by Keertivaas S (@justanordinaryperson).</description>
    <link>https://dev.to/justanordinaryperson</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%2F1368806%2F799706a9-4302-45d0-be78-561b5bad04d9.png</url>
      <title>DEV Community: Keertivaas S</title>
      <link>https://dev.to/justanordinaryperson</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/justanordinaryperson"/>
    <language>en</language>
    <item>
      <title>python revision</title>
      <dc:creator>Keertivaas S</dc:creator>
      <pubDate>Fri, 07 Mar 2025 15:57:59 +0000</pubDate>
      <link>https://dev.to/justanordinaryperson/python-revision-290m</link>
      <guid>https://dev.to/justanordinaryperson/python-revision-290m</guid>
      <description></description>
      <category>python</category>
    </item>
    <item>
      <title>React Day Berlin 2024: Remote Reflections</title>
      <dc:creator>Keertivaas S</dc:creator>
      <pubDate>Sat, 11 Jan 2025 13:39:50 +0000</pubDate>
      <link>https://dev.to/justanordinaryperson/react-day-berlin-2024-remote-reflections-4172</link>
      <guid>https://dev.to/justanordinaryperson/react-day-berlin-2024-remote-reflections-4172</guid>
      <description>&lt;p&gt;I had the opportunity to attend React Day Berlin 2024 as a remote participant. It was indeed a fantastic virtual experience, packed with insightful talks that challenged my preconceived notions and provided valuable takeaways. Key topics discussed include React 19 features, React Compiler, AI Integration for React components and React Server Components.&lt;/p&gt;

&lt;p&gt;Here are some of the key takeaways from the talks I attended:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React Server Components and AI: Tejas's talk on "React Server Components in AI Applications" was a standout. He convincingly demonstrated how leveraging Server Components to handle AI tasks server-side can significantly boost performance and enhance user experience. Importantly, his presentation dispelled the fear of AI replacing frontend developers, instead highlighting how AI can be used as a powerful tool to enhance our work.&lt;/li&gt;
&lt;li&gt;The State Management Odyssey: "From Redux to Zustand to Jotai to Zustand to Custom: Our State Management Horror Story" provided valuable lessons about the trade-offs associated with different state management libraries. It emphasized that popularity doesn't necessarily equate to the best fit for every project. The talk even suggested that sometimes the best approach might be minimal state management, relying on useState or useContext where appropriate.&lt;/li&gt;
&lt;li&gt;React Query: A Balanced Perspective: "React Query - The Bad Parts" offered a much-needed dose of realism, debunking some of the common myths surrounding React Query/Tanstack Query. The speaker clearly outlined the situations where React Query is truly beneficial and where alternative approaches might be more suitable.&lt;/li&gt;
&lt;li&gt;Fine-Grained Reactivity: "Fine-Grained Reactivity Without Any Compiler" extended beyond the basic usage of useMemo, useCallback, and useEffect, providing valuable insights into optimizing component updates for improved performance.&lt;/li&gt;
&lt;li&gt;The Promise of a React Compiler: "React Compiler - The Missing Piece for Optimizing React Applications" was a truly thought-provoking discussion. The potential performance gains and developer experience enhancements that a dedicated React compiler could unlock are truly exciting.&lt;/li&gt;
&lt;li&gt;RUM: A Crucial Tool for Performance Monitoring: "Evaluating React Application Performance with a Sip of RUM" highlighted the critical importance of Real User Monitoring (RUM) in understanding real-world application performance. Analyzing RUM data provides invaluable insights for identifying and addressing performance bottlenecks.
&lt;/li&gt;
&lt;li&gt;StyleX: Atomic CSS with a Focus on Performance: "Atomic Power: the Story of StyleX" introduced StyleX, an atomic CSS-in-JS library prioritizing performance and maintainability. While similar to Tailwind, StyleX offers some notable improvements.
&lt;/li&gt;
&lt;li&gt;Building for the Present: A Pragmatic Approach: "Build Things That Don’t Scale at All" challenged the conventional wisdom of always building for extreme scalability. This talk emphasized the importance of focusing on solving the current problem effectively and avoiding over-engineering.&lt;/li&gt;
&lt;li&gt;Iterative Component Design: A Key to Success: "Little Bits of Iterative Component Design" stressed the importance of breaking down complex components into smaller, more manageable pieces and iteratively refining them. This iterative design process should be a core part of our development workflow.&lt;/li&gt;
&lt;li&gt;Universal React: Weighing the Trade-offs: "Age of Universal React - whats the catch" provided a balanced perspective on the challenges and limitations of adopting a Universal React approach, where React is used across various devices (web, mobile, etc.). The talk also briefly touched upon React Strict Mode, a recent addition from Facebook.&lt;/li&gt;
&lt;li&gt;Enhancing Forms with Server Components: "Enhancing forms with React Server Components" demonstrated the significant advantages of handling form logic on the server-side. This approach has the potential to significantly improve performance, enhance security, and create a more seamless user experience.
&lt;/li&gt;
&lt;li&gt;Vector Search and Embeddings: A Glimpse into the Future: "Decoding Vector Search and Embeddings for React Developers" provided a fascinating introduction to these emerging technologies. The potential of vector search and embeddings to revolutionize search and recommendation systems is truly immense.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Overall, React Day Berlin 2024 was an incredibly enriching experience and I am eager to experiment with these concepts and see how they can be applied at work..&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>javascript</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Sending Functions as Props in React</title>
      <dc:creator>Keertivaas S</dc:creator>
      <pubDate>Sun, 28 Jul 2024 15:08:12 +0000</pubDate>
      <link>https://dev.to/justanordinaryperson/sending-functions-as-props-in-react-215d</link>
      <guid>https://dev.to/justanordinaryperson/sending-functions-as-props-in-react-215d</guid>
      <description>&lt;p&gt;I am sure this concept would be a little too basic for some of you but just wanted to write about it as I faced a real world scenario for this usecase.&lt;/p&gt;

&lt;p&gt;At work, I was presented with a challenge. There were 2 screens in the UI (Lets assume mobile UI - The screens were quite small). I was supposed to upload data (assuming images) in both the screens and the submit button in the second screen would submit the entire data (both the images).&lt;/p&gt;

&lt;p&gt;Solution : &lt;/p&gt;

&lt;p&gt;So, the state for the files would be in a common component. The state and the setter function would be passed as a prop to the respective components. &lt;/p&gt;

&lt;p&gt;Since the state is maintained in the common component, there is no loss of data.&lt;/p&gt;

&lt;p&gt;Simple code example (just a basic skeleton) :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const UploadComponent = (props) =&amp;gt; {
  const { files, setFiles } = props;
  const onFileUploadA = (file) =&amp;gt; {
    setFiles([...files, file]); // Appending file
  };
  return (
    &amp;lt;Upload onSubmit={(file) =&amp;gt; onFileUploadA(file)} /&amp;gt;
  );
};

const CommonComponent = (props) =&amp;gt; {
  const [files, setFiles] = useState([]);
  return (
    &amp;lt;&amp;gt;
      &amp;lt;UploadComponent {...props} files={files} setFiles={setFiles} back={false} /&amp;gt; {/* Front page */}
      &amp;lt;UploadComponent {...props} files={files} setFiles={setFiles} back={true} /&amp;gt; {/* Back page */}
    &amp;lt;/&amp;gt;
  );
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second upload just appends the new upload to the list of uploads, thus preventing loss of data.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
      <category>react</category>
    </item>
    <item>
      <title>The simplest explanation I have seen for Closures in JS (Credits : roadmap.sh)</title>
      <dc:creator>Keertivaas S</dc:creator>
      <pubDate>Sun, 28 Jul 2024 13:58:38 +0000</pubDate>
      <link>https://dev.to/justanordinaryperson/the-simplest-explanation-i-have-seen-for-closures-in-js-credits-roadmapsh-1agc</link>
      <guid>https://dev.to/justanordinaryperson/the-simplest-explanation-i-have-seen-for-closures-in-js-credits-roadmapsh-1agc</guid>
      <description>&lt;p&gt;Wanted to share here, the simplest explanation that I have ever seen on the web, for the famous Closures topic. (Credits : roadmap.sh)&lt;/p&gt;

&lt;p&gt;A closure is a function that has access to its outer function scope even after the outer function has returned. This means a closure can remember and access variables and arguments of its outer function even after the function has finished.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function outer() {
  const name = 'Roadmap';

  function inner() {
    console.log(name);
  }

  return inner;
}

const closure = outer();
closure(); // Roadmap

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, the inner function has access to the name variable of the outer function even after the outer function has returned. Therefore, the inner function forms a closure.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Lazy Loading :)</title>
      <dc:creator>Keertivaas S</dc:creator>
      <pubDate>Sat, 06 Jul 2024 13:36:54 +0000</pubDate>
      <link>https://dev.to/justanordinaryperson/lazy-loading--3f11</link>
      <guid>https://dev.to/justanordinaryperson/lazy-loading--3f11</guid>
      <description>&lt;p&gt;Sometimes a user might not click and view a part of the code. In that case, it doesn't make sense to load the component before we render the main screen. This is where Lazy Loading comes in.&lt;/p&gt;

&lt;p&gt;Code example :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { lazy, Suspense, useState } from 'react';

// Import component A directly (eager loading)
import A from './A';

// Lazy load component B
const B = React.lazy(() =&amp;gt; import('./B'));

const App = () =&amp;gt; {
  const [showComponentB, setShowComponentB] = useState(false);

  const handleClick = () =&amp;gt; {
    setShowComponentB(true);
  };

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;A /&amp;gt;
      &amp;lt;button onClick={handleClick}&amp;gt;Click to view Component B&amp;lt;/button&amp;gt;
      {showComponentB &amp;amp;&amp;amp; (
        &amp;lt;Suspense fallback={&amp;lt;div&amp;gt;Loading...&amp;lt;/div&amp;gt;}&amp;gt;
          &amp;lt;B /&amp;gt;
        &amp;lt;/Suspense&amp;gt;
      )}
    &amp;lt;/div&amp;gt;
  );
};

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: &lt;/p&gt;

&lt;p&gt;Here, the code imports A directly, assuming it's needed on the landing page (eager loading). B is lazy loaded using React.lazy and Suspense. &lt;/p&gt;

&lt;p&gt;The render doesn't have to wait for B, before rendering A :)&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>?? (Nullish coalescing) vs || (Logical OR) in Javascript</title>
      <dc:creator>Keertivaas S</dc:creator>
      <pubDate>Sun, 16 Jun 2024 11:29:30 +0000</pubDate>
      <link>https://dev.to/justanordinaryperson/-nullish-coalescing-vs-logical-or-in-javascript-2l88</link>
      <guid>https://dev.to/justanordinaryperson/-nullish-coalescing-vs-logical-or-in-javascript-2l88</guid>
      <description>&lt;p&gt;Both Nullish Coalescing Operator (??) and Logical OR (||) operator are often used in JavaScript to provide a default value to variables. These help us prevent any unexpected behavior in our code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nullish Coalescing Operator (??):&lt;/strong&gt; This is specifically designed to handle situations where the left operand might be unintentionally left unassigned (null) or missing a a value (undefined). It only considers null and undefined as nullish values.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Logical OR (||):&lt;/strong&gt; This is useful when you want a default value if the left operand is any falsy value. This includes null, undefined, 0, empty string (""), false, and NaN.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lets take these examples :&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;If you want to check and avoid printing empty values, use the Logical OR Operator (||).&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;console.log("" || "Hello")&lt;/code&gt; // "Hello"&lt;br&gt;
&lt;code&gt;console.log("" ?? "Hello")&lt;/code&gt; // ""&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;If 0 or Boolean false is a valid return value in your use-case, use ?? (Nullish coalescing).&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;console.log(0 || "Hello")&lt;/code&gt; // "Hello"&lt;br&gt;
&lt;code&gt;console.log(0 ?? "Hello")&lt;/code&gt; // 0&lt;/p&gt;

&lt;p&gt;&lt;code&gt;console.log(false || "Hello")&lt;/code&gt; // "Hello"&lt;br&gt;
&lt;code&gt;console.log(false ?? "Hello")&lt;/code&gt; // false&lt;/p&gt;

&lt;p&gt;&lt;code&gt;console.log(0 || "Hello")&lt;/code&gt; // "Hello"&lt;br&gt;
&lt;code&gt;console.log(0 ?? "Hello")&lt;/code&gt; // 0&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;If you are only checking for undefined or null, you can go for either one of them :&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;console.log(undefined ?? "Hello")&lt;/code&gt; // "Hello"&lt;br&gt;
&lt;code&gt;console.log(undefined || "Hello")&lt;/code&gt; // "Hello"&lt;/p&gt;

&lt;p&gt;&lt;code&gt;console.log(null ?? "Hello")&lt;/code&gt; // "Hello"&lt;br&gt;
&lt;code&gt;console.log(null || "Hello")&lt;/code&gt; // "Hello"&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>React useRef is easy!</title>
      <dc:creator>Keertivaas S</dc:creator>
      <pubDate>Sat, 15 Jun 2024 13:06:09 +0000</pubDate>
      <link>https://dev.to/justanordinaryperson/react-useref-is-easy-4bj2</link>
      <guid>https://dev.to/justanordinaryperson/react-useref-is-easy-4bj2</guid>
      <description>&lt;p&gt;We can use useRef instead of the usual way (event.target.value) to fetch an input value, in a much easier hassle free way. This example below can make you familiar with useRef, enabling you to sue it for more difficult scenarios:&lt;/p&gt;

&lt;p&gt;const unameRef = React.useRef(); //declaration&lt;/p&gt;

&lt;p&gt;const [userName, setUserName] = React.useState(''); // I have a sample variable to set username to&lt;/p&gt;

&lt;p&gt;// Usage - React element&lt;/p&gt;



&lt;p&gt;// A simple usage with useEffect to set focus to a form field&lt;/p&gt;

&lt;p&gt;useEffect(() =&amp;gt; {&lt;br&gt;
    unameRef.current.focus();&lt;br&gt;
  }, []);&lt;/p&gt;

&lt;p&gt;// handleChange function&lt;/p&gt;

&lt;p&gt;function handleChange(event){&lt;br&gt;
   setUserName(unameRef.current.value);&lt;br&gt;
}&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Creating a deep copy of a JS Object</title>
      <dc:creator>Keertivaas S</dc:creator>
      <pubDate>Sat, 01 Jun 2024 10:35:57 +0000</pubDate>
      <link>https://dev.to/justanordinaryperson/creating-a-deep-copy-of-a-js-object-342e</link>
      <guid>https://dev.to/justanordinaryperson/creating-a-deep-copy-of-a-js-object-342e</guid>
      <description>&lt;h2&gt;
  
  
  Using Lodash :
&lt;/h2&gt;

&lt;p&gt;const _ = require('lodash');&lt;/p&gt;

&lt;p&gt;const originalObject = {&lt;br&gt;
  prop1: "value1",&lt;br&gt;
  prop2: {&lt;br&gt;
    nestedProp: "value2"&lt;br&gt;
  }&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;const deepCopy = _.cloneDeep(originalObject);&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Underscore js :
&lt;/h2&gt;

&lt;p&gt;const _ = require('underscore');&lt;br&gt;
const deepclone = require('underscore.deepclone');&lt;/p&gt;

&lt;p&gt;_.mixin(deepclone);  // Add deepClone function to Underscore&lt;/p&gt;

&lt;p&gt;const originalObject = {&lt;br&gt;
  prop1: "value1",&lt;br&gt;
  prop2: {&lt;br&gt;
    nestedProp: "value2"&lt;br&gt;
  }&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;However, using packages like lodash and underscore can be heavy as &lt;/p&gt;

&lt;p&gt;const deepCopy = _.deepClone(originalObject);&lt;/p&gt;

&lt;h2&gt;
  
  
  A combination of JSON.parse and JSON.stringify :
&lt;/h2&gt;

&lt;p&gt;const originalObject = {&lt;br&gt;
  prop1: "value1",&lt;br&gt;
  prop2: {&lt;br&gt;
    nestedProp: "value2"&lt;br&gt;
  }&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;const deepCopy = JSON.parse(JSON.stringify(originalObject));&lt;/p&gt;

&lt;h2&gt;
  
  
  When to use JSON.parse(JSON.stringify(obj)) :
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Simple Data Transfer: If you're dealing with basic objects containing only primitive values (strings, numbers, booleans) and need to transfer them between environments that understand JSON, this method can be a quick and straightforward solution.&lt;/li&gt;
&lt;li&gt;Shallow Copy with Specific Data Loss: If you intentionally want to remove functions, Dates, or other complex data types during the copy process, this method can achieve that. However, be aware of the potential data loss.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Issues with JSON.parse(JSON.stringify(obj)) :
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Data Loss: This method can lose data during the conversion process. Functions, Dates, and other complex data types might not be accurately represented in JSON format and could be lost during parsing back to an object.&lt;/li&gt;
&lt;li&gt;Circular References: It can't handle circular references (objects referencing themselves) in the data. This can lead to infinite loops during parsing.&lt;/li&gt;
&lt;li&gt;Performance: While seemingly simple, stringifying and parsing a large object can be less performant compared to dedicated deep copy functions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Advantages of using lodash clonedeep or underscore package based solution :
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Preserves Data: These methods are designed to handle various data types and maintain their integrity during the copy process.&lt;/li&gt;
&lt;li&gt;Handles Circular References: They can effectively deal with circular references in the object structure, preventing infinite loops.&lt;/li&gt;
&lt;li&gt;Optimized for Deep Copying: Deep copy libraries like Lodash are often optimized for performance when creating deep copies of complex objects.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion :
&lt;/h2&gt;

&lt;p&gt;In most cases, for reliable deep copying of objects in JavaScript applications, Lodash's _.cloneDeep or similar methods from other libraries like Underscore (with extensions) are preferred choices. They offer better performance, handle complex data types and circular references, and provide a more robust solution for deep copying objects.&lt;/p&gt;

&lt;h2&gt;
  
  
  Edit :
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Adding another method of cloning - structuredClone, which is a built in function in Javascript : Credits : &lt;a class="mentioned-user" href="https://dev.to/jonrandy"&gt;@jonrandy&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;const originalObject = {&lt;br&gt;
  prop1: "value1",&lt;br&gt;
  prop2: {&lt;br&gt;
    nestedProp: "value2"&lt;br&gt;
  }&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;originalObject.itself = originalObject;&lt;/p&gt;

&lt;p&gt;const deepCopy = structuredClone(originalObject);&lt;/p&gt;

&lt;p&gt;The above way preserves circular references as well as does not require external packages to download!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Containment and Specialization</title>
      <dc:creator>Keertivaas S</dc:creator>
      <pubDate>Sun, 28 Apr 2024 09:43:35 +0000</pubDate>
      <link>https://dev.to/justanordinaryperson/containment-and-specialization-bie</link>
      <guid>https://dev.to/justanordinaryperson/containment-and-specialization-bie</guid>
      <description>&lt;p&gt;In ReactJS, Containment and Specialization are techniques for building reusable and maintainable components. Here's a breakdown of each concept:&lt;/p&gt;

&lt;p&gt;Containment:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Concept: Containment focuses on creating generic components that can hold any content passed to them as children.&lt;/li&gt;
&lt;li&gt;Implementation: This is achieved using the special children prop in React. The component renders the content of the children prop within its own JSX structure.&lt;/li&gt;
&lt;li&gt;Benefits:

&lt;ul&gt;
&lt;li&gt;Promotes reusability: Generic components can be used in various contexts with different content.&lt;/li&gt;
&lt;li&gt;Improves code maintainability: You don't need to duplicate the same layout code for different components.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Specialization:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Concept: Specialization builds upon Containment. It involves creating a more specific component by inheriting functionality and structure from a generic container component.&lt;/li&gt;
&lt;li&gt;Implementation: You create a new component that takes the generic container component as a prop and renders its own specific content within the container's layout.&lt;/li&gt;
&lt;li&gt;Benefits:

&lt;ul&gt;
&lt;li&gt;Leverages existing code: You reuse the layout and styles from the generic component.&lt;/li&gt;
&lt;li&gt;Improves code organization: Groups related functionalities into separate components.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Key Points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Containment and Specialization promote the DRY (Don't Repeat Yourself) principle, reducing code duplication.&lt;/li&gt;
&lt;li&gt;They encourage component composition, which is a core concept in React for building complex UIs from smaller, reusable pieces.&lt;/li&gt;
&lt;li&gt;While React discourages traditional inheritance for components, containment provides a more flexible and composable approach.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>react</category>
    </item>
    <item>
      <title>useState and useReducer</title>
      <dc:creator>Keertivaas S</dc:creator>
      <pubDate>Sat, 27 Apr 2024 09:17:35 +0000</pubDate>
      <link>https://dev.to/justanordinaryperson/usestate-and-usereducer-2i60</link>
      <guid>https://dev.to/justanordinaryperson/usestate-and-usereducer-2i60</guid>
      <description>&lt;p&gt;Similarities between useState and useReducer:&lt;/p&gt;

&lt;p&gt;Both useState and useReducer are React hooks used for managing state in functional components. They share these key points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;State Management: They both allow you to store and update data within a component that can trigger re-renders when the state changes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Functional Components: They are exclusive to functional components in React, providing an alternative to the setState method in class components.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Return Value: Both hooks return an array containing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The current state value.&lt;/li&gt;
&lt;li&gt;   A function to update the state (setter function for useState and dispatch function for useReducer).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When to use useState:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simple State: It's ideal for managing a single piece of state, especially primitive values (strings, numbers, booleans) or single objects/arrays.&lt;/li&gt;
&lt;li&gt;Straightforward Updates: The state updates are easy to understand and don't require complex logic or dependencies on previous state values.&lt;/li&gt;
&lt;li&gt;Readability: You prioritize keeping your component code concise and easy to reason about.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When to use useReducer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Complex State Management: You're dealing with multiple state values that are updated interdependently or require handling previous state values.&lt;/li&gt;
&lt;li&gt;Centralized Logic: You want to centralize state update logic in a separate reducer function to improve code maintainability and reusability.&lt;/li&gt;
&lt;li&gt;Advanced Patterns: You need to implement advanced state management patterns like state history or optimistic updates.&lt;/li&gt;
&lt;li&gt;Performance Optimization (Deep Updates): You're working with deep updates in the component tree, where useReducer can offer slight performance improvements because dispatch functions can be passed down without recreating functions on every render.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>react</category>
    </item>
    <item>
      <title>Reducing Bundle size of a Frontend application by optimizing Lodash imports</title>
      <dc:creator>Keertivaas S</dc:creator>
      <pubDate>Wed, 20 Mar 2024 14:26:49 +0000</pubDate>
      <link>https://dev.to/justanordinaryperson/reducing-bundle-size-of-a-frontend-application-by-optimizing-lodash-imports-4299</link>
      <guid>https://dev.to/justanordinaryperson/reducing-bundle-size-of-a-frontend-application-by-optimizing-lodash-imports-4299</guid>
      <description>&lt;p&gt;We recently analyzed the bundle size of our frontend application and noticed the Lodash package was taking up a significant amount of space. Lodash offers many useful utilities for common tasks like filtering, sorting, mapping and manipulating data. However, importing the entire library increases bundle size considerably.&lt;/p&gt;

&lt;p&gt;We decided to optimize our usage of Lodash to reduce this bundle size. Upon inspection, we found we were importing the whole library using imports like &lt;/p&gt;

&lt;p&gt;const lodash = require('lodash');&lt;br&gt;
 and &lt;br&gt;
const _ = require('lodash');&lt;/p&gt;

&lt;p&gt;While convenient, this brings in all of Lodash's functions regardless of what we actually use.&lt;/p&gt;

&lt;p&gt;A better approach is to import only the specific functions needed. For example, using &lt;/p&gt;

&lt;p&gt;const merge = require('lodash/merge');&lt;br&gt;
 and &lt;br&gt;
const cloneDeep = require('lodash/cloneDeep');&lt;/p&gt;

&lt;p&gt;We import just those individual methods rather than the entire library. This avoids unnecessary code and reduces bundle size.&lt;/p&gt;

&lt;p&gt;We also noticed imports like &lt;/p&gt;

&lt;p&gt;const { get } = require('lodash');&lt;br&gt;
 &lt;br&gt;
that destructure the &lt;br&gt;
get function. However, this still imports the whole Lodash library first before extracting the function. For even better optimization, we can import directly from the sub-module like &lt;/p&gt;

&lt;p&gt;const get = require('lodash/get');&lt;/p&gt;

&lt;p&gt;This imports only the needed &lt;br&gt;
get&lt;br&gt;
 code without the full library.&lt;/p&gt;

&lt;p&gt;By analyzing usage and optimizing imports in this way, we were able to significantly reduce the size of lodash in our bundle. What seemed like minor changes made a meaningful impact on bundle size. With some inspection of imports, libraries like Lodash can be used efficiently without the overhead of unused code. This optimization is especially important as bundle size directly impacts performance and user experience.&lt;/p&gt;

&lt;p&gt;Reference :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://lodash.com/per-method-packages"&gt;https://lodash.com/per-method-packages&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>opensource</category>
      <category>lodash</category>
    </item>
  </channel>
</rss>
