<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Nithyanandam Venu</title>
    <description>The latest articles on Forem by Nithyanandam Venu (@nithyanandam).</description>
    <link>https://forem.com/nithyanandam</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%2F847847%2Fd1a1ab98-b76c-41b1-9240-c6a8103974e5.jpeg</url>
      <title>Forem: Nithyanandam Venu</title>
      <link>https://forem.com/nithyanandam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/nithyanandam"/>
    <language>en</language>
    <item>
      <title>Immutability and why you need to know its importance!</title>
      <dc:creator>Nithyanandam Venu</dc:creator>
      <pubDate>Thu, 14 Mar 2024 16:22:13 +0000</pubDate>
      <link>https://forem.com/nithyanandam/immutability-and-why-you-need-to-know-its-importance-3l1h</link>
      <guid>https://forem.com/nithyanandam/immutability-and-why-you-need-to-know-its-importance-3l1h</guid>
      <description>&lt;p&gt;If you are working with javascript, you must give a lot of importance to the immutability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is immutability?&lt;/strong&gt;&lt;br&gt;
Immutable means something that cannot be changed. In programming, immutable is used to describe a value that cannot be changed after it's been set. But do you know Primitives in JavaScript: Naturally Immutable! specifically, arrays and objects that we commonly use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it matters?&lt;/strong&gt;&lt;br&gt;
Let's see with a simple example. (kept the example very naive to showcase the impact of immutability, in real time you would be passing around your objects more than you imagine knowingly or unknowingly!)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let person = {name:"John", age: 30};
const original = () =&amp;gt; {
   console.log(person.name,person.age)
}
original() // prints john,30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's assume, we have another function where I want to just change the name for another person and print.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let person = {name:"John", age: 30};
const original = () =&amp;gt; {
   console.log(person.name,person.age)
}
original() // prints john,30
const newPerson = (newsperson) {
  person.name = 'jake';
  console.log(newsperson.name,newsperson.age)
}
pass(person) //print jake,40
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;what would the original() function print now? *&lt;em&gt;john,30, or Jake,40.&lt;br&gt;
orginal() //it would print jake,40 as well *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Because of the immutable nature of the object. If you pass around your data in objects and array lot over your application without worrying about immutability, trust me you are going to headache on where your original values got changed.&lt;/p&gt;

&lt;p&gt;The simplest way to overcome is this to take a copy of the object. It can be a deep clone or shallow based on your need.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const newPerson = (newsperson) {
  person.name = 'jake';
  console.log(newsperson.name,newsperson.age)
}
pass(...person) //taking clone of the object instead of direct reference so orignal object remains same!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why Is Immutability Important?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Once an immutable value is set, it isn't changed. Rather a new value is created. This makes the value predictable and consistent throughout the code. So it aids in managing the state throughout the application. Plus immutability is a key principle in state management frameworks, such as Redux.&lt;/li&gt;
&lt;li&gt;Code becomes simpler and less error-prone when data structures don't change unexpectedly. This also simplifies debugging and maintenance.&lt;/li&gt;
&lt;li&gt;Embracing immutability is in line with functional programming principles, leading to fewer side effects and more predictable code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope now you get the picture of why immutability is very important to keep your code predictable and adhere to the functional programming principle and mainly to avoid unwanted debugging headaches.&lt;/p&gt;

&lt;p&gt;Ref: &lt;a href="https://www.freecodecamp.org/"&gt;https://www.freecodecamp.org/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>immutability</category>
      <category>functional</category>
      <category>webdev</category>
    </item>
    <item>
      <title>React 19 is coming and What's new?</title>
      <dc:creator>Nithyanandam Venu</dc:creator>
      <pubDate>Sun, 10 Mar 2024 07:17:58 +0000</pubDate>
      <link>https://forem.com/nithyanandam/react-19-is-coming-and-whats-new-1i0l</link>
      <guid>https://forem.com/nithyanandam/react-19-is-coming-and-whats-new-1i0l</guid>
      <description>&lt;p&gt;As I eagerly await React 19, let's explore the exciting new features it brings to the table with its release.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;React Compiler&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of the most common challenges in React development is avoiding unnecessary re-renders. Although we've had tools like &lt;strong&gt;useMemo&lt;/strong&gt;, &lt;strong&gt;useCallback&lt;/strong&gt;, and **memo **for manual state caching to mitigate this issue, React Compiler promises to address it automatically without requiring manual intervention. This should result in noticeable improvements in performance and the prevention of unwanted re-renders.&lt;/p&gt;

&lt;p&gt;The great news is that "React Compiler is no longer a research project: the compiler now powers instagram.com in production, and we are working to ship the compiler across additional surfaces at Meta and to prepare the first open-source release - React Dev".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Action&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Another exciting addition is the introduction of &lt;strong&gt;Actions&lt;/strong&gt;, providing a more efficient way to interact with the server. Actions allow you to attach a function to DOM elements such as &lt;code&gt;&amp;lt;/form&amp;gt;&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form action={search}&amp;gt;
 &amp;lt;input name="query" /&amp;gt;
 &amp;lt;button type="submit"&amp;gt;Search&amp;lt;/button&amp;gt;
 &amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When using an action, React manages the lifecycle of data submission for you, offering hooks like **useFormStatus **and useFormState to access the current state and response of the form action.&lt;/p&gt;

&lt;p&gt;By default, Actions are submitted within a transition, ensuring that the current page remains interactive while the action is processing. Additionally, Actions support async functions, allowing the use of async/await in transitions. This enables the display of pending UI with the isPending state of a transition when an async request starts, and maintains the pending UI until the update is applied.&lt;/p&gt;

&lt;p&gt;Another noteworthy feature is &lt;strong&gt;useOptimistic&lt;/strong&gt; for managing optimistic state updates, but we won't delve into the details of that just yet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;New Features in React Canary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For those eager to try out new stable features before the public release, React Canary will prove invaluable. This allows React developers to gather feedback from the community before the stable release, facilitating further improvements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;React Server Components, Asset Loading, Document Metadata,&lt;/strong&gt; and &lt;strong&gt;Actions&lt;/strong&gt; are all available in React Canary already.&lt;/p&gt;

&lt;p&gt;There's still more to come. In React 19, additional improvements are on the horizon, including long-requested enhancements like support for Web Components. The focus now is on finalizing these changes, preparing for release, updating documentation for new features, and announcing what's included.&lt;/p&gt;

&lt;p&gt;It's clear that significant changes and improvements are on the way, and I can't wait to give them a try. Let me know which feature you're most excited about—I'm personally intrigued by the React Compiler and React Server Components.&lt;/p&gt;

&lt;p&gt;For more Info follow &lt;strong&gt;&lt;a href="https://react.dev/blog"&gt;https://react.dev/blog&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>react19</category>
      <category>whatsnew</category>
    </item>
    <item>
      <title>Why to use keys in list in React?</title>
      <dc:creator>Nithyanandam Venu</dc:creator>
      <pubDate>Tue, 19 Apr 2022 10:15:45 +0000</pubDate>
      <link>https://forem.com/nithyanandam/why-to-use-keys-in-list-in-react-2m6f</link>
      <guid>https://forem.com/nithyanandam/why-to-use-keys-in-list-in-react-2m6f</guid>
      <description>&lt;p&gt;Recently i came across a Linkedin post about use case of keys in react without specifying the details under the hood. Hence decided to decode it out in this post. Now Let's see what's happening under the hood of react when we add keys to our list.&lt;/p&gt;

&lt;p&gt;Ever wonder how react detect the Dom has been updated? React uses the state of art diffing algorithm to do reconciliation. And do you know it have o(n) complexity? &lt;/p&gt;

&lt;p&gt;The algorithm follows this two basic principle&lt;/p&gt;

&lt;p&gt;1.Two elements of different types will produce different trees.&lt;br&gt;
2.The developer can hint at which child elements may be stable across different renders with a key prop.&lt;/p&gt;

&lt;p&gt;Ok how this helps out us, lets take one example DOM list&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;ul&amp;gt;&lt;br&gt;
&amp;lt;li&amp;gt;1&amp;lt;/li&amp;gt;&lt;br&gt;
&amp;lt;li&amp;gt;2&amp;lt;/li&amp;gt;&lt;br&gt;
&amp;lt;/ul&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now let's say you want to add one item at the start.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;ul&amp;gt;&lt;br&gt;
&amp;lt;li&amp;gt;3&amp;lt;/li&amp;gt;&lt;br&gt;
&amp;lt;li&amp;gt;1&amp;lt;/li&amp;gt;&lt;br&gt;
&amp;lt;li&amp;gt;2&amp;lt;/li&amp;gt;&lt;br&gt;
&amp;lt;/ul&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now react will compare both this Dom and have to iterate then have to figure out both the list item 1 and list item 2 have been not changed. Then have to add the list item 3 at start.&lt;/p&gt;

&lt;p&gt;Let's just imagine if our list have 1000 of elements which need to be updated frequently. Our app would be have a worst performance nightmare.&lt;/p&gt;

&lt;p&gt;Now lets see how this works differently when you add a key &lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;ul&amp;gt;&lt;br&gt;
&amp;lt;li key='a'&amp;gt;3&amp;lt;/li&amp;gt;&lt;br&gt;
&amp;lt;li key='b'&amp;gt;1&amp;lt;/li&amp;gt;&lt;br&gt;
&amp;lt;li key='c'&amp;gt;2&amp;lt;/li&amp;gt;&lt;br&gt;
&amp;lt;/ul&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now when react compare the Dom, it exactly knows a has been introduced newly and no change has happened on b and c so it will just add the a list item in the list. In this way it will avoid iteration as well. &lt;/p&gt;

&lt;p&gt;Also make sure you are not keeping the index as key which is not recommended by react as it might result in unexpected re-render behaviours. Make sure to use unique key elements always.&lt;/p&gt;

&lt;p&gt;Hope now it's clear that why adding a key would be very important in react and how it can improve the performance so well.&lt;/p&gt;

&lt;p&gt;you can check more about the diffing algorithm &lt;a href="https://reactjs.org/docs/reconciliation.html#recursing-on-children"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How I build my own stand-up reminder</title>
      <dc:creator>Nithyanandam Venu</dc:creator>
      <pubDate>Mon, 18 Apr 2022 07:11:27 +0000</pubDate>
      <link>https://forem.com/nithyanandam/how-i-build-my-own-stand-up-reminder-45i4</link>
      <guid>https://forem.com/nithyanandam/how-i-build-my-own-stand-up-reminder-45i4</guid>
      <description>&lt;p&gt;Before we get into details, let me put out the reason behind this effort. As the pandemic hits and WFH starts, my physical activity has been reduced drastically. And I was spending even more time on my desk compared to the office environment. Since my entertainment also lies within my desks such as gaming and reading. The continuing situation put a toll on my back hence I decided to act on it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1Z3DOHyE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lcjio2izv6n59nbr5372.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1Z3DOHyE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lcjio2izv6n59nbr5372.gif" alt="Back Hurts" width="400" height="168"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As the saying goes ‘start small’. I have narrowed down the possible option to improve my physical activity and decided to follow it up. The simplest one is standing up at regular intervals after sitting down at the desk for a while.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_iPIQGiF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y5tf4ca02vlk8k7eqcjd.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_iPIQGiF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y5tf4ca02vlk8k7eqcjd.gif" alt="Time to begin" width="480" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is something that can be accommodated easily in the schedule right. Hence I picked it up and searched for a stand-up reminder on google. Unfortunately, there are not any simple options present to use effectively on my laptop.&lt;/p&gt;

&lt;p&gt;And yea obviously I don’t want to extend this into my smartphone. As my digital time is already too high and also it would easily make me get distracted by my smartphone.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--14TrMrPJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ar4e81vm2wyr9oy8u434.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--14TrMrPJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ar4e81vm2wyr9oy8u434.gif" alt="No SmartPhone" width="307" height="307"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ok time to get hands dirty. So in hindsight, I planned out a simple HTML page that can load out an audio/video in a set period of interval time, and keeping the chrome tab on would be the only downside of it I thought also dumped the idea of using audio since I couldn’t find any proper web API to get audio content. Decided to go with youtube video as it was an easy option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iOVWG3Dd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/twzn1ikala4c8hom9oa7.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iOVWG3Dd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/twzn1ikala4c8hom9oa7.gif" alt="Time to Code" width="220" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So coded out a simple HTML page and when I tried to autoplay on the iframe. Chrome was smart enough to not let me autoplay the video with sound as an access policy. &lt;/p&gt;

&lt;p&gt;Even though that made me annoyed, kudos to chrome which doesn’t want to annoy the user by playing autoplay video even worse if the user is not even in the tab, he would have to go through all tabs and figure out where the sound was coming from.&lt;/p&gt;

&lt;p&gt;So it was a pretty good fix and access policy from chrome. What I thought would be a 5 mins work taught me about chrome access policy and youtube embed options.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lA_RkJ__--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/puc34g9tsocisa2mtipq.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lA_RkJ__--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/puc34g9tsocisa2mtipq.gif" alt="Got Stuck" width="324" height="244"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now I am almost stuck and also I don’t want to spend more time on it. Time to rethink my decision!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AY1EgsA3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9qxi9g74o0ysgsru25vn.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AY1EgsA3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9qxi9g74o0ysgsru25vn.gif" alt="Rethink strategy" width="320" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ok now let’s ditch chrome and go for a native app. Do I know native desktop app development? no obviously. Currently is there any place where you can’t run javascript?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1dU04WZW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zm8yem2dyivj8trlym4m.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1dU04WZW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zm8yem2dyivj8trlym4m.gif" alt="Exciting Idea" width="498" height="216"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here comes the saviour electron. Going to do the same implementation but just going to transfer it to the native app. According to my assumption, it should work 100%. Again there is no time to learn the design fully.&lt;/p&gt;

&lt;p&gt;Took out the hello world example and modified it a little specifically removing the same origin cors policy meta in HTML to load out the youtube video.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--paw65_wu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ub6sz72741b7zlo0bk57.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--paw65_wu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ub6sz72741b7zlo0bk57.gif" alt="It works" width="480" height="260"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hola! It worked like a charm!!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sPBFALp_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9m0h2ofxmclt8j0t7y6s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sPBFALp_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9m0h2ofxmclt8j0t7y6s.png" alt="Standup reminder app screenshot" width="700" height="519"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Set your duration in minutes. Put your favourite video URL from youtube. Our Standup Reminder is ready to go! Minimize the app and do your stuff. Once the time interval hits, the video will play automatically. &lt;/p&gt;

&lt;p&gt;For example, you can set it to 60 minutes and it will play every one-hour interval and you can use it to remind yourself to take a break and stand up.&lt;/p&gt;

&lt;p&gt;Don’t want the reminder just close the app. Was it too much to do for a simple stand-up reminder? Might be, but why not have fun when you can!!&lt;/p&gt;

&lt;p&gt;So this is how I build my own stand-up reminder. It took an hour almost. Was it worth doing? absolutely. Want to check out the project and use it for yourself &lt;a href="https://github.com/vbinithyanandamv/Stand-Up-Reminder"&gt;https://github.com/vbinithyanandamv/Stand-Up-Reminder&lt;/a&gt;. Check out the repo.&lt;/p&gt;

&lt;p&gt;Should I polish it out and publish it as an app and share it with non-programming folks let me know in the comment. Have any feature ideas for this please feel free to let me know!&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
