<?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: varunprashar5</title>
    <description>The latest articles on Forem by varunprashar5 (@varunprashar5).</description>
    <link>https://forem.com/varunprashar5</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%2F224197%2F3da0ff5c-b47a-4942-99a7-e1af2f38f40d.JPG</url>
      <title>Forem: varunprashar5</title>
      <link>https://forem.com/varunprashar5</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/varunprashar5"/>
    <language>en</language>
    <item>
      <title>Optimization may overkill Performance (React)</title>
      <dc:creator>varunprashar5</dc:creator>
      <pubDate>Thu, 02 Sep 2021 06:25:02 +0000</pubDate>
      <link>https://forem.com/varunprashar5/react-optimisation-may-overkill-performance-11og</link>
      <guid>https://forem.com/varunprashar5/react-optimisation-may-overkill-performance-11og</guid>
      <description>&lt;p&gt;𝗝𝘂𝗻𝗶𝗼𝗿 𝗗𝗲𝘃: 𝗪𝗲 𝘀𝗵𝗼𝘂𝗹𝗱 𝘄𝗿𝗮𝗽 𝗲𝘃𝗲𝗿𝘆 𝗳𝘂𝗻𝗰𝘁𝗶𝗼𝗻 𝗶𝗻𝘀𝗶𝗱𝗲 "𝘂𝘀𝗲𝗖𝗮𝗹𝗹𝗯𝗮𝗰𝗸" 𝗵𝗼𝗼𝗸 𝘁𝗼 𝗯𝗼𝗼𝘀𝘁 𝗽𝗲𝗿𝗳𝗼𝗿𝗺𝗮𝗻𝗰𝗲.&lt;/p&gt;

&lt;p&gt;𝗦𝗲𝗻𝗶𝗼𝗿 𝗗𝗲𝘃: 𝗦𝗲𝗿𝗶𝗼𝘂𝘀𝗹𝘆 (𝘄/𝘁 𝗰𝗵𝗲𝗰𝗸𝗶𝗻𝗴 𝗽𝗿𝗼𝗳𝗶𝗹𝗶𝗻𝗴)? 𝗜 𝘁𝗵𝗶𝗻𝗸 𝗶𝘁 𝘄𝗶𝗹𝗹 𝗯𝗲 𝗮 𝗽𝗲𝗿𝗳𝗼𝗿𝗺𝗮𝗻𝗰𝗲 𝗸𝗶𝗹𝗹!&lt;/p&gt;

&lt;p&gt;^ ^ In continuation to the last post (&lt;a href="https://dev.to/varunprashar5/don-t-overoptimize-your-react-app-2nba"&gt;React.memo&lt;/a&gt;):&lt;/p&gt;

&lt;p&gt;When a component gets a function as a prop from its parent, then whenever a parent is rendered, its child component will get re-rendered every time no matter even if you have used React.memo().&lt;/p&gt;

&lt;p&gt;Do checkout the video for more details:&lt;br&gt;
&lt;a href="https://youtu.be/5aH_b5pUAHI"&gt;https://youtu.be/5aH_b5pUAHI&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;𝗕𝗶𝗴𝗟𝗶𝘀𝘁 𝗶𝘁𝗲𝗺𝘀={𝗶𝘁𝗲𝗺𝘀} 𝗶𝘁𝗲𝗺𝗖𝗹𝗶𝗰𝗸={𝗶𝘁𝗲𝗺𝗖𝗹𝗶𝗰𝗸} /&amp;gt;&lt;/p&gt;

&lt;p&gt;In above line, even if  is passed via React.memo, It will still re-render because itemClick function will get re-created every time the parent component is rendered.&lt;/p&gt;

&lt;p&gt;𝗜 𝗵𝗮𝘃𝗲𝗻'𝘁 𝗰𝗵𝗮𝗻𝗴𝗲𝗱 𝘁𝗵𝗲 𝗳𝘂𝗻𝗰𝘁𝗶𝗼𝗻, 𝗯𝘂𝘁 𝘄𝗵𝘆 𝘄𝗶𝗹𝗹 𝗶𝘁 𝘀𝘁𝗶𝗹𝗹 𝗿𝗲-𝗿𝗲𝗻𝗱𝗲𝗿?&lt;/p&gt;

&lt;p&gt;This is how Javascript works, you should know that two references are never equal.&lt;/p&gt;

&lt;p&gt;[1,2] === [1,2] //false&lt;br&gt;
1==1 //true (primitives are equal)&lt;/p&gt;

&lt;p&gt;Primitive values will be the same on every re-render but objects will be different (functions are objects in Javascript).&lt;/p&gt;

&lt;p&gt;To prevent this, just wrap your function with useCallback hook.&lt;/p&gt;

&lt;p&gt;𝘂𝘀𝗲𝗖𝗮𝗹𝗹𝗯𝗮𝗰𝗸(𝗳𝘂𝗻𝗰𝘁𝗶𝗼𝗻, [𝗱𝗲𝗽𝗲𝗻𝗱𝗲𝗻𝗰𝗶𝗲𝘀])&lt;br&gt;
//Here we are saying to use the same function on re-renders&lt;br&gt;
//If you pass an array of dependencies, then whenever any of the dependencies change, then a new function will be used.&lt;/p&gt;

&lt;p&gt;𝗗𝗼𝗲𝘀 𝗶𝘁 𝗺𝗲𝗮𝗻 𝘁𝗵𝗮𝘁 𝗜 𝘀𝗵𝗼𝘂𝗹𝗱 𝘄𝗿𝗮𝗽 𝗲𝘃𝗲𝗿𝘆 𝗳𝘂𝗻𝗰𝘁𝗶𝗼𝗻 𝗶𝗻𝘀𝗶𝗱𝗲 𝗺𝘆 𝗰𝗼𝗺𝗽𝗼𝗻𝗲𝗻𝘁 𝘄𝗶𝘁𝗵 𝘂𝘀𝗲𝗖𝗮𝗹𝗹𝗯𝗮𝗰𝗸?&lt;/p&gt;

&lt;p&gt;You should 𝗡𝗘𝗩𝗘𝗥 do that, Here are the reasons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Optimisation always does come with a cost, it's a special function that will never be garbage collected and will always have a reference in the memory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Extra check for the different values in the array of dependencies to see if these dependencies are changed then they have to recreate the newer function.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Don’t forget that useCallback() hook is called every time the parent component renders. Even useCallback() returns the same function object, still the inline function is re-created on every re-rendering (useCallback() just skips it).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;𝗛𝗼𝘄 𝘁𝗼 𝗱𝗲𝗰𝗶𝗱𝗲 𝘄𝗵𝗲𝘁𝗵𝗲𝗿 𝘁𝗼 𝘂𝘀𝗲 𝘂𝘀𝗲𝗖𝗮𝗹𝗹𝗯𝗮𝗰𝗸() 𝗼𝗿 𝗻𝗼𝘁?&lt;/p&gt;

&lt;p&gt;There will never be a single answer to this problem, So always run your profiler and see what performance gain you will get and then decide.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Don't overoptimize your React App</title>
      <dc:creator>varunprashar5</dc:creator>
      <pubDate>Tue, 24 Aug 2021 06:04:09 +0000</pubDate>
      <link>https://forem.com/varunprashar5/don-t-overoptimize-your-react-app-2nba</link>
      <guid>https://forem.com/varunprashar5/don-t-overoptimize-your-react-app-2nba</guid>
      <description>&lt;p&gt;𝗢𝗽𝘁𝗶𝗺𝗶𝘀𝗶𝗻𝗴 𝘆𝗼𝘂𝗿 𝗥𝗲𝗮𝗰𝘁 𝗔𝗽𝗽&lt;/p&gt;

&lt;p&gt;Do checkout the video for more details:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/2woSmgfUjC8"&gt;https://youtu.be/2woSmgfUjC8&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you have a parent-child component structure then Whenever the parent state changes it will re-render.&lt;br&gt;
Do you know it will even re-render your child? No matter if your child uses any prop or not it will still re-render.&lt;/p&gt;

&lt;p&gt;Ideally, Child should re-render only if: parent prop or method used inside the child is changed.&lt;/p&gt;

&lt;p&gt;𝗛𝗼𝘄 𝘁𝗼 𝗽𝗿𝗲𝘃𝗲𝗻𝘁 𝘂𝗻𝗻𝗲𝗰𝗲𝘀𝘀𝗮𝗿𝘆 𝗿𝗲-𝗿𝗲𝗻𝗱𝗲𝗿𝘀 ?&lt;br&gt;
The solution is "𝗥𝗲𝗮𝗰𝘁.𝗺𝗲𝗺𝗼"&lt;/p&gt;

&lt;p&gt;React.memo (is a higher-order component) takes the component and memoizes the rendered output of the wrapped component.&lt;/p&gt;

&lt;p&gt;So whenever there is a re-render in the parent, For a child it will compare the props and if all the props are the same it reuses the memoized result skipping the next rendering.&lt;/p&gt;

&lt;p&gt;𝗢𝗯𝘀𝗲𝗿𝘃𝗮𝘁𝗶𝗼𝗻:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pressing the "click" button, updates the state due to which  re-renders&lt;/li&gt;
&lt;li&gt; is re-rendered every time "Parent" is re-rendered (even it is not using any parent state)&lt;/li&gt;
&lt;li&gt; is not re-rendered when "Parent" is re-rendered (As it is using memoised result)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;𝗜𝗺𝗽𝗼𝗿𝘁𝗮𝗻𝘁 𝗽𝗼𝗶𝗻𝘁𝘀:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;If you are using function as a prop in your child, it will still re-render even if props are the same in comparison (let's discuss it in the next post)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you are thinking to have every component to use React.memo then it may overkill the performance in some scenarios where it will first compare the props if they are not the same it will still do the re-rendering (extra comparison check)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Do check the profiler to actually figure out if it will be worth using it&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If a child is re-rendering it doesn't mean it is costly unless it is doing the "commit" phase which actually does the real DOM changes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Before preventing re-renders, Do fix your SLOW renders.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Do share your thoughts in the comments&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How Javascript Engine's Work?</title>
      <dc:creator>varunprashar5</dc:creator>
      <pubDate>Tue, 29 Jun 2021 07:29:03 +0000</pubDate>
      <link>https://forem.com/varunprashar5/how-javascript-engine-s-work-3cb0</link>
      <guid>https://forem.com/varunprashar5/how-javascript-engine-s-work-3cb0</guid>
      <description>&lt;p&gt;𝗝𝗮𝘃𝗮𝘀𝗰𝗿𝗶𝗽𝘁 𝗘𝗻𝗴𝗶𝗻𝗲 is a program that executes the javascript code. These days relevant modern engines use just-in-time compilation for improved performance. (As per Wikipedia)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbaivubsmprmukfu2jyqc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbaivubsmprmukfu2jyqc.png" alt="javascript engine"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;𝗗𝗶𝗳𝗳𝗲𝗿𝗲𝗻𝘁 𝘀𝘁𝗲𝗽𝘀 𝗼𝗳 𝗝𝗮𝘃𝗮𝘀𝗰𝗿𝗶𝗽𝘁 𝗲𝗻𝗴𝗶𝗻𝗲 𝗽𝗶𝗽𝗲𝗹𝗶𝗻𝗲 𝗮𝗿𝗲  (Generic for any JS Engine):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Javascript source code is passed to "Parser"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Parser divides the code into multiple tokens&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is converted into AST (Abstract Syntax Tree), a tree-like structure that represents functions, conditionals, scopes etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This AST is passed to the interpreter which converts the code into Bytecode.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;At the same time engine is actually running the Javascript code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bytecode is used by optimizing compiler along with profiling data&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;"Optimizing compiler" make certain assumptions based on profiling data and produces highly optimized machine code.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Sometimes there is a case where the 'optimization' assumption is incorrect and then it goes back to the previous version via the "Deoptimize" phase (where it actually becomes the overhead to us)&lt;/p&gt;

&lt;p&gt;JS Engine usually optimizes "hot functions" and uses inline caching techniques to optimize the code.&lt;/p&gt;

&lt;p&gt;𝗟𝗲𝘁'𝘀 𝘀𝗲𝗲 𝘁𝗵𝗲𝘀𝗲 𝗶𝗻 𝗩𝟴:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Interpreter is called "Ignition".&lt;/li&gt;
&lt;li&gt;Optimizing compiler is called "TurboFan".&lt;/li&gt;
&lt;li&gt;Apart from Parser, there is a "pre-parser" that checks for syntax and tokens&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;𝗔 𝗿𝗲𝗰𝗲𝗻𝘁 𝘂𝗽𝗱𝗮𝘁𝗲 𝗶𝗻 𝗩𝟴: "Sparkplug" is introduced which is present between "Ignition" &amp;amp; "TurboFan" which is also called Fast Compiler.&lt;/p&gt;

&lt;p&gt;𝗡𝗼𝘁𝗲: These are high-level step's that most of the JS engines goes through and every engine goes through their own set of steps for further optimizations.&lt;/p&gt;

&lt;p&gt;They do have stack, heap, garbage collector and is out of scope for this post.&lt;/p&gt;

&lt;p&gt;Do share more about JS engines in the comments&lt;/p&gt;

&lt;p&gt;Checkout my youtube channel for more such content:&lt;br&gt;
&lt;a href="https://www.youtube.com/channel/UCJErruzdazYFQfDdb6avbtA" rel="noopener noreferrer"&gt;https://www.youtube.com/channel/UCJErruzdazYFQfDdb6avbtA&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>𝗛𝗼𝘄 𝘁𝗼 𝗳𝗶𝗻𝗱 "UNUSED' 𝗝𝗔𝗩𝗔𝗦𝗖𝗥𝗜𝗣𝗧 𝗮𝗻𝗱 𝗖𝗦𝗦 𝗰𝗼𝗱𝗲 𝗼𝗻 𝘆𝗼𝘂𝗿 𝗽𝗮𝗴𝗲? 🤔
</title>
      <dc:creator>varunprashar5</dc:creator>
      <pubDate>Thu, 17 Jun 2021 09:45:35 +0000</pubDate>
      <link>https://forem.com/varunprashar5/unused-3688</link>
      <guid>https://forem.com/varunprashar5/unused-3688</guid>
      <description>&lt;h3&gt;
  
  
  You can find it using Chrome via "Dev Tools" 😊
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open dev tools (F12)&lt;/li&gt;
&lt;li&gt;Type: Ctrl + Shift + P&lt;/li&gt;
&lt;li&gt;Type: "Coverage" and select "show coverage" from the result.&lt;/li&gt;
&lt;li&gt;New window with the "Coverage" tab will be shown&lt;/li&gt;
&lt;li&gt;Click Icon "Start Instrumenting Coverage And Reload Page"&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So it will reload the page and show the information in the table &lt;br&gt;
with "Url", "Type", "UnusedBytes", "Usage Visualization"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F89l2z1pndkq7h5s2l768.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F89l2z1pndkq7h5s2l768.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;𝗨𝘀𝗮𝗴𝗲 𝗩𝗶𝘀𝘂𝗮𝗹𝗶𝘇𝗮𝘁𝗶𝗼𝗻:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Red section of the bar is unused bytes&lt;/li&gt;
&lt;li&gt;Green section is used bytes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;𝗦𝗼 𝘄𝗵𝗮𝘁 𝘁𝗵𝗲 𝗻𝗲𝘅𝘁 𝘀𝘁𝗲𝗽? 🤨&lt;br&gt;
Refactoring your codebase so that each page only ships the Javascript and CSS that it needs (this can be a tricky part 🙃)&lt;/p&gt;

&lt;p&gt;Do share your thoughts and other suggestions in the comments&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>css</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>What is AbortController in Javascript?</title>
      <dc:creator>varunprashar5</dc:creator>
      <pubDate>Wed, 09 Jun 2021 18:53:00 +0000</pubDate>
      <link>https://forem.com/varunprashar5/what-is-abortcontroller-in-javascript-2ca2</link>
      <guid>https://forem.com/varunprashar5/what-is-abortcontroller-in-javascript-2ca2</guid>
      <description>&lt;p&gt;&lt;strong&gt;Do you know what is AbortConroller?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is a Web API provided by DOM Standard. &lt;/p&gt;

&lt;p&gt;The "AbortController" interface represents a Controller object that allows you to abort one or more Web requests as and when desired.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Properties: signal&lt;/strong&gt;&lt;br&gt;
It returns "AbortSignal" object instance to communicate with DOM request&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;const controller = new AbortController();&lt;br&gt;
const signal = controller.signal;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Controller has one method:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;controller.abort();&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When you abort an async operation, the promise rejects with a DOMException named "AbortError"&lt;/p&gt;

&lt;p&gt;Do checkout the code snippet where it is aborting the request if it takes more than &lt;strong&gt;3 seconds&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//create a new AbortController object 
const controller = new AbortController();
const options = {
  method: 'POST',
  signal: controller.signal, 
  body: JSON.stringify({
    name:'Varun',
    work:'Dev'
  })
};  

// Abord the request after 3 seconds
setTimeout(() =&amp;gt; controller.abort(), 3000);

//Send API Request to the server
fetch('/saveUser', options)
.then(response =&amp;gt; {
  console.log(response.status);
})
.catch(error =&amp;gt; console.error('Request Timeout'));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So what's the other alternative? Do share in comments.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Do you know React Hooks Flow?</title>
      <dc:creator>varunprashar5</dc:creator>
      <pubDate>Sun, 06 Jun 2021 11:47:27 +0000</pubDate>
      <link>https://forem.com/varunprashar5/do-you-know-react-hooks-flow-24gi</link>
      <guid>https://forem.com/varunprashar5/do-you-know-react-hooks-flow-24gi</guid>
      <description>&lt;p&gt;Understanding "Hooks Flow" is very important and sometimes even experienced React developers miss a few points.&lt;/p&gt;

&lt;p&gt;Thanks to "Donavon" for sharing the beautiful flow diagram.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqckkq831tb6gffm4juzi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqckkq831tb6gffm4juzi.png" alt="React Hooks Flow"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;React Hooks flow includes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Mount&lt;/li&gt;
&lt;li&gt;Update (when state changes based on any event)&lt;/li&gt;
&lt;li&gt;UnMount&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Mount:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run the lazy initializer (functions passed to useState or useReducer)&lt;/li&gt;
&lt;li&gt;Continue the rest of the render function&lt;/li&gt;
&lt;li&gt;React updates the DOM&lt;/li&gt;
&lt;li&gt;It runs LayoutEffects&lt;/li&gt;
&lt;li&gt;Browser paints the screen to reflect &lt;/li&gt;
&lt;li&gt;Runs the effects&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Update: (When the user make any event it update the state)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Runs the render phase&lt;/li&gt;
&lt;li&gt;React updates DOM&lt;/li&gt;
&lt;li&gt;Cleanup LayoutEffects first&lt;/li&gt;
&lt;li&gt;Run LayoutEffects&lt;/li&gt;
&lt;li&gt;Browser paints the screen&lt;/li&gt;
&lt;li&gt;Cleanup the effects first&lt;/li&gt;
&lt;li&gt;Run the effects in the render&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Unmount: Component gets removed from the screen (navigate to other screen or from user event)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Cleanup LayoutEffects&lt;/li&gt;
&lt;li&gt;Cleanup Effects&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Note: Never confuse them with lifecycle methods in Class Components.&lt;/p&gt;

&lt;p&gt;Let's share more about hooks in the comments below.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>What is Prop Drilling in React? Understanding Context API - Part 1</title>
      <dc:creator>varunprashar5</dc:creator>
      <pubDate>Sun, 23 May 2021 16:58:56 +0000</pubDate>
      <link>https://forem.com/varunprashar5/what-is-prop-drilling-in-react-understanding-context-api-part-1-381l</link>
      <guid>https://forem.com/varunprashar5/what-is-prop-drilling-in-react-understanding-context-api-part-1-381l</guid>
      <description>&lt;p&gt;If you have started learning or exploring react then you must have come to a situation where you are passing your props down to 3rd - 4th or Nth level in your components hierarchy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjtkhe3jx2fhoxhxny8oj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjtkhe3jx2fhoxhxny8oj.png" alt="prop drilling in react"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/PlulYcZ4n3k" rel="noopener noreferrer"&gt;Prop Drilling by Example&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The intermediary components need not do anything with those props but are acting as a pathway to pass those props to the child which actually needs them.&lt;/p&gt;

&lt;p&gt;This particular problem is called "Prop Drilling".&lt;/p&gt;

&lt;p&gt;In the cover image, you can see that I am actually passing "Complete Todo" and "Delete Todo" from my TodoApp component down to the "Todo" Component.&lt;/p&gt;

&lt;p&gt;TodoList component needs nothing to do with these props and is acting as an intermediary here.&lt;/p&gt;

&lt;h4&gt;
  
  
  Few problems with Prop Drilling:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Useless re-renders will be there in case that prop is changed from the parent via an event&lt;/li&gt;
&lt;li&gt;Easy to maintain the code in case there is a change request and is prone to errors&lt;/li&gt;
&lt;li&gt;Becomes very difficult when we have a deeper level of nesting and we are passing the props&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  How can we prevent this Prop Drilling?
&lt;/h4&gt;

&lt;p&gt;We can prevent it by using "Context API" in React. It has two components named:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Context.Provider&lt;/li&gt;
&lt;li&gt;Context.Consumer&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Apart from that, we can even use the "useContext" hook instead of Context. Consumer and is a preferred way.&lt;/p&gt;

&lt;p&gt;If we can combine Context API with useReducer Hook, It can be a powerful tool for having our own central state management.&lt;/p&gt;

&lt;p&gt;But it is suggested by React team that we should only use "Context API" in case we have less frequent updates in these props.&lt;/p&gt;

&lt;h4&gt;
  
  
  Do follow me on:
&lt;/h4&gt;

&lt;p&gt;Linkedin: &lt;a href="https://www.linkedin.com/in/varunprashar5/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/varunprashar5/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Twitter: &lt;a href="https://twitter.com/Varunprashar" rel="noopener noreferrer"&gt;https://twitter.com/Varunprashar&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Different React Patterns for Enterprise Apps</title>
      <dc:creator>varunprashar5</dc:creator>
      <pubDate>Wed, 05 May 2021 08:51:46 +0000</pubDate>
      <link>https://forem.com/varunprashar5/different-react-patterns-for-enterprise-apps-2c7k</link>
      <guid>https://forem.com/varunprashar5/different-react-patterns-for-enterprise-apps-2c7k</guid>
      <description>&lt;p&gt;Are you a React Developer?&lt;/p&gt;

&lt;p&gt;If you want to Simplify large React applications by separating your component logic, state and display properties to make React components more flexible then do explore more about different patterns &amp;amp; approaches you should follow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Compound Components&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Render Props&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provider Pattern&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Combining Pattern&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Component Injection&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What is your strategy, approach and thought process in creating such enterprise React Apps?&lt;/p&gt;

&lt;p&gt;Let me know if you want to learn more about any pattern or topic in React.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>javascript</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Do you know javascript? </title>
      <dc:creator>varunprashar5</dc:creator>
      <pubDate>Mon, 12 Oct 2020 18:06:17 +0000</pubDate>
      <link>https://forem.com/varunprashar5/do-you-know-javascript-3307</link>
      <guid>https://forem.com/varunprashar5/do-you-know-javascript-3307</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9vkfHdt5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rsx7mbz60po9w41zjujb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9vkfHdt5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rsx7mbz60po9w41zjujb.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Can you guess the output? Do explain it in the comment section
&lt;/h1&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>node</category>
      <category>beginners</category>
    </item>
    <item>
      <title>What the heck is RPC ? </title>
      <dc:creator>varunprashar5</dc:creator>
      <pubDate>Wed, 09 Sep 2020 06:54:03 +0000</pubDate>
      <link>https://forem.com/varunprashar5/what-the-heck-is-rpc-4g7e</link>
      <guid>https://forem.com/varunprashar5/what-the-heck-is-rpc-4g7e</guid>
      <description>&lt;p&gt;Do you know about RPC ?&lt;/p&gt;

&lt;h2&gt;
  
  
  Background:
&lt;/h2&gt;

&lt;p&gt;For communication between front-end client and back-end server we have different ways :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;REST APIs&lt;/li&gt;
&lt;li&gt;GraphQL&lt;/li&gt;
&lt;li&gt;RPC&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These days GraphQL is being quite used due to lower network hits &amp;amp; less communication between mobile team, front-end and back-end developer. Still we don’t make the whole app using graphQL but try to follow hybrid approach of using REST APIs + GraphQL as per use-cases.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is it ?
&lt;/h2&gt;

&lt;p&gt;RPC (Remote Procedure call) is same as calling a function in Javascript, Python etc taking a method name and arguments. It is like executing a block of code on another server.&lt;br&gt;
RPC is just a bunch of functions, but in the context of an HTTP API, that entails putting the method in the URL and the arguments in the query string or body.&lt;/p&gt;

&lt;h2&gt;
  
  
  There are few specifications for it like:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;XML-RPC&lt;/li&gt;
&lt;li&gt;JSON-RPC&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Slack has provided its RPC based Web API : &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://api.slack.com/web"&gt;https://api.slack.com/web&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Its is most often used in “Microservices” based architecture where these microservcies communicates with each other via RPC calls.&lt;/p&gt;

&lt;p&gt;Do you think if there are any performance gains if we are using it ?&lt;br&gt;
Is there any limitation or challenges of using it ?&lt;br&gt;
Do share in comments&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>java</category>
    </item>
    <item>
      <title>Best way to learn any programming language</title>
      <dc:creator>varunprashar5</dc:creator>
      <pubDate>Tue, 08 Sep 2020 17:51:46 +0000</pubDate>
      <link>https://forem.com/varunprashar5/best-way-to-learn-a-new-tech-or-programming-language-56om</link>
      <guid>https://forem.com/varunprashar5/best-way-to-learn-a-new-tech-or-programming-language-56om</guid>
      <description>&lt;p&gt;I remember when I was fresher and how difficult it was to acquire new technology without any guidance. I use to take random steps and try to do everything based on my understanding.&lt;br&gt;
There were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No plan&lt;/li&gt;
&lt;li&gt;No mentor&lt;/li&gt;
&lt;li&gt;No consistency&lt;/li&gt;
&lt;li&gt;lack of maturity &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Due to this I faced multiple problems and it took me may be triple time in grasping a particular technology.&lt;/p&gt;

&lt;p&gt;So considering this, I would suggest the below strategy before you dive into learning any new tech:&lt;/p&gt;

&lt;h1&gt;
  
  
  Create a road-map and action plan first (get it verified by experts in that tech)
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Understand the core concepts of the language&lt;/li&gt;
&lt;li&gt;Practice those core concepts with multiple real time small tasks&lt;/li&gt;
&lt;li&gt;Create at least 5-6 small applications to grasp more understanding (predecided in your road-map)&lt;/li&gt;
&lt;li&gt;Find the best practices for that particular language&lt;/li&gt;
&lt;li&gt;Play with all your learning &amp;amp; try to make one good project (making sure you are using most of your learning)&lt;/li&gt;
&lt;li&gt;Find out the concepts which are complex and difficult to get in 1 go and make proper plan to practice it until you are comfortable with them.&lt;/li&gt;
&lt;li&gt;Dive deeper into understanding the language behaviour , its insights and do in-depth analysis&lt;/li&gt;
&lt;li&gt;Once you reach there, Check stack-overflow and see the kind of questions other devs are asking in same tech and see if you are able to provide solution&lt;/li&gt;
&lt;li&gt;Practice Practice &amp;amp; Practice (this is the whole essence at the end)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Before that must connect with guys who are master in that language over &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linkedin &lt;/li&gt;
&lt;li&gt;Join discord servers &lt;/li&gt;
&lt;li&gt;Join their slack channels&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Be consistent (2-3 hrs/day) and try to live with this whole journey, at the end you must be between beginner to intermediate to this new tech or programming language&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Do share your experiences and thoughts on the same in comments.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>productivity</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Boost Web Performance: content-visibility (chrome 85)</title>
      <dc:creator>varunprashar5</dc:creator>
      <pubDate>Wed, 05 Aug 2020 04:41:45 +0000</pubDate>
      <link>https://forem.com/varunprashar5/boost-web-performance-content-visibility-chrome-85-55gm</link>
      <guid>https://forem.com/varunprashar5/boost-web-performance-content-visibility-chrome-85-55gm</guid>
      <description>&lt;p&gt;To boost web app performance, A new css property is introduced with the launch of chrome 85.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;content-visibility allows the element's rendering work, including layout and painting, until it is needed. &lt;/li&gt;
&lt;li&gt;If heavy part of your content is not visible to the screen, using this property will make the initial load much faster.&lt;/li&gt;
&lt;li&gt;You have control to make it automated or via a script to handle it.&lt;/li&gt;
&lt;li&gt;The 'auto' keyword allows for the user-agent to manage content visibility based on proximity to the viewport.&lt;/li&gt;
&lt;li&gt;Whereas 'hidden' keyword allows full script control of content visibility.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>css</category>
      <category>news</category>
    </item>
  </channel>
</rss>
