<?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: Ajay Raja</title>
    <description>The latest articles on DEV Community by Ajay Raja (@ajaythewizard).</description>
    <link>https://dev.to/ajaythewizard</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%2F1038359%2F6ff1d3d1-c70e-4a57-8b84-4bc962caabfc.png</url>
      <title>DEV Community: Ajay Raja</title>
      <link>https://dev.to/ajaythewizard</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ajaythewizard"/>
    <language>en</language>
    <item>
      <title>Is Flutter really a App Development Framework?</title>
      <dc:creator>Ajay Raja</dc:creator>
      <pubDate>Sat, 01 Mar 2025 09:47:50 +0000</pubDate>
      <link>https://dev.to/ajaythewizard/is-flutter-really-a-app-development-framework-3o6h</link>
      <guid>https://dev.to/ajaythewizard/is-flutter-really-a-app-development-framework-3o6h</guid>
      <description>&lt;h2&gt;
  
  
  Critical Look
&lt;/h2&gt;

&lt;p&gt;While trying Flutter for first time, The Above question rose in my mind. After doing some research from I Found the answer for this question. These post is simply my opinion and research about how it works. Let me mention it clearly, I'm not a hater of Flutter. I love the Tech and it's architecture but You need to know whether It works like A App Development Framework.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rendering
&lt;/h2&gt;

&lt;p&gt;For those who knew about Shaders and it's working and where it was used, You will get my point easily because Flutter uses Shaders for Every part of UI. . But why? I had a &lt;em&gt;WTF moment&lt;/em&gt; when I discovered this.&lt;/p&gt;

&lt;p&gt;For Those who don't know about Shaders, Let me explain to you in simple terms. Shaders are program written in C like Language that handles how to paint or draw in-form of pixel in Screen. They are primarily used in Game Development. Every Android and iOS Platform knew how to draw a text in Screen or Any Element in Screen because It was created in a way to do all kind of basic operations like rendering Text, Button and so on. But In Flutter, We are adding a extra layer that handles these drawing work.&lt;/p&gt;

&lt;p&gt;Shaders were introduced to draw complex and custom elements in Games because Video Game needs custom elements. Platform had all things in it. Basic Element Rendering were predefined at OS level But Flutter ignores all those things and adding extra layer that redo these drawing stuffs. They did it to add custom animations. I totally get that but Still They could have done that for only Elements with Animation. Instead They did it for all elements even to Basic Elements like Text.&lt;/p&gt;

&lt;p&gt;Now Think about this, Why do we need to ship the code that contains  How to paint a text in Screen? It contains shaders which is slower than Native Platform. Shaders could never close to Platform Rendering. These are adding some &lt;em&gt;Shitty Fatty&lt;/em&gt; code that bloats our App Size and Performance. It has both worst space and time complexity. The Advantage of this approach is Better Developer Experience. Why do need to sacrifice both Space and Time just for Better DX? Kotlin MultiPlatform (KMP) solves the same problem with native compilation and Better DX. Then Why Flutter?&lt;/p&gt;

&lt;p&gt;I'm not a Flutter hater. But I don't like this approach for building apps. It looks like Game Engine without Physics. Only Difference between Impeller Engine at Flutter and Game Engine is Physics. In other words, Impeller is Game Engine without Physics. Why the hell we need Game Engine for building App Development?&lt;/p&gt;

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

&lt;p&gt;If you found my language a bit critical,I'm Sorry because This post is written in that kind of way. Here my thoughts about Flutter, It should be made as Game Development Engine. I think Krafton, Inc found this truth and They did developed their game with that. My Final Conclusion is that Flutter Framework should focus as Game Development Framework instead of App Development Framework. It's working Mechanism and DX suits well for Mobile Game Development rather than App Development. I hope You understands well.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Is useEffect in React is actually an Effect?</title>
      <dc:creator>Ajay Raja</dc:creator>
      <pubDate>Wed, 11 Sep 2024 13:08:06 +0000</pubDate>
      <link>https://dev.to/ajaythewizard/is-useeffect-in-react-is-actually-an-effect-42j3</link>
      <guid>https://dev.to/ajaythewizard/is-useeffect-in-react-is-actually-an-effect-42j3</guid>
      <description>&lt;h2&gt;
  
  
  React : I Choose You
&lt;/h2&gt;

&lt;p&gt;I started my Own Journey with React JS as &lt;strong&gt;My Starter Pokemon&lt;/strong&gt; to explore the Javascript World of Frameworks. At my First Glance, I fell for it because it reduces a lots of tons of Imperative DOM Manipulation Code. I really love the Idea of Framework automatically Manipulating DOM based on State.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdaily-now%2Fimage%2Fupload%2Fs--g1KjaYgb--%2Ff_auto%2Fv1725900090%2Fugc%2Fcontent_b89ac2ca-87be-4cdb-adcf-1f49f26d875f" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdaily-now%2Fimage%2Fupload%2Fs--g1KjaYgb--%2Ff_auto%2Fv1725900090%2Fugc%2Fcontent_b89ac2ca-87be-4cdb-adcf-1f49f26d875f" alt="Screenshot 2024-09-09 221116" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At First, I didn't consider Size of React and Memory it consumes which could defeat &lt;strong&gt;Snorlax&lt;/strong&gt; at Weight.&lt;br&gt;
After learning React, I came across lots of Framework like Vue, Angular, Svelte. When I finally reaches SolidJS, My Eyes were opened&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdaily-now%2Fimage%2Fupload%2Fs--drOAiBkY--%2Ff_auto%2Fv1725900445%2Fugc%2Fcontent_5dc34e29-1888-4cd4-bae1-a8f17a194492" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdaily-now%2Fimage%2Fupload%2Fs--drOAiBkY--%2Ff_auto%2Fv1725900445%2Fugc%2Fcontent_5dc34e29-1888-4cd4-bae1-a8f17a194492" alt="download (1)" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I started following Live Stream and Articles of Ryan Carniato, The Author of SolidJS. He totally changed the way I see Frameworks. I started understanding Reactivity Systems of Javascript Frameworks. When I turn back a bit and saw My Starter Pokemon React and It's reactivity and rendering system, I couldn't control my Laugh&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdaily-now%2Fimage%2Fupload%2Fs--7uy9cwwv--%2Ff_auto%2Fv1725900681%2Fugc%2Fcontent_f4af4491-fab3-4c7e-b9d7-16aaf48757d8" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdaily-now%2Fimage%2Fupload%2Fs--7uy9cwwv--%2Ff_auto%2Fv1725900681%2Fugc%2Fcontent_f4af4491-fab3-4c7e-b9d7-16aaf48757d8" alt="images" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's like I was fooled from the start. Why there is a need of rerunning everything whenever a State changes? If So Then Why do we really need a hook named as &lt;code&gt;useEffect&lt;/code&gt; to act as a side-effect.&lt;/p&gt;
&lt;h2&gt;
  
  
  Now Get into the Title of Article
&lt;/h2&gt;

&lt;p&gt;I titled this Article as &lt;code&gt;Is useEffect in React is actually an Effect?&lt;/code&gt; to open Your Eyes about React like &lt;em&gt;Vegapunk opened eyes of People about Government ( Sorry for Spoiling to OP Fans )&lt;/em&gt; . There is lots of think to criticise about it. So Today is the Day for &lt;code&gt;useEffect&lt;/code&gt; who lied the most by hiding it's true name.&lt;/p&gt;

&lt;p&gt;If You are the beginner or You asks some beginner at React, They would give explanation of &lt;code&gt;useEffect&lt;/code&gt; as &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A function that reruns whenever values at dependency array changes. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If You are that person, You are really lucky to knew the Truth that You are taught wrong. React reruns whenever something changes So There is not need to rerun a function because There is no need for it . Here I am going to explain the Truth about it&lt;/p&gt;
&lt;h2&gt;
  
  
  What does Effect really mean?
&lt;/h2&gt;

&lt;p&gt;Let me explain what does effect is really mean. In Reactivity system, Effect is actually called as &lt;em&gt;Side Effect&lt;/em&gt;. Let's start with an example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John Doe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nf"&gt;createEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;New name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;},[&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here &lt;code&gt;createEffect&lt;/code&gt; function accepts a function which reruns whenever values in Array from second argument changes. Here function inside &lt;code&gt;createEffect&lt;/code&gt; is a &lt;em&gt;side effect&lt;/em&gt; of &lt;code&gt;name&lt;/code&gt; in other words that function depends on the state &lt;code&gt;name&lt;/code&gt;. Whenever the value of name is changed, side effect should rerun. This is what &lt;em&gt;Side Effect&lt;/em&gt; really about.&lt;/p&gt;

&lt;h2&gt;
  
  
  What React actually does?
&lt;/h2&gt;

&lt;p&gt;Let me write same code in terms of React&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setName&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John Doe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;New name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;},[&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="nf"&gt;setName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Jane Doe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Whenever &lt;code&gt;setName&lt;/code&gt; called, &lt;code&gt;useEffect&lt;/code&gt; would rerun. I totally get it. Let me give equivalent code by simply removing &lt;code&gt;useEffect&lt;/code&gt;. It also works because React's &lt;code&gt;useState&lt;/code&gt; won't create any reactive state&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setName&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John Doe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;New name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;setName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Jane Doe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;TADA!&lt;/em&gt; It works fine in React because it reruns whenever state from &lt;code&gt;useState&lt;/code&gt; &lt;br&gt;
 changes. Let me give another example to explain &lt;code&gt;useEffect&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setName&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John Doe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setAge&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;New name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;setAge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now whenever age is changed, &lt;code&gt;console.log("New name", name)&lt;/code&gt; also be executed which is not what we want. So We wrap it with &lt;code&gt;useEffect&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setName&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John Doe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setAge&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;New name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;},[&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="nf"&gt;setName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Jane Doe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is fixed now. Therefore &lt;code&gt;useEffect&lt;/code&gt; is actually preventing the execution which is exactly opposite as Effects. I hope You understand  what it really does. Here proper explaination for &lt;code&gt;useEffect&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;useEffect is hook that lets you executes only when there is a change in state&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I knew &lt;em&gt;Side Effect&lt;/em&gt; explanation is a similar but It's like &lt;em&gt;Opposite Side of a Coin&lt;/em&gt;.&lt;br&gt;
In explanation of Side effect&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Side Effects are the functions that executes whenever there is a change in state&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In &lt;em&gt;Reactivity System&lt;/em&gt;, Nothing other than Effects reruns and Effects are the function that only runs whenever the state changes.&lt;/p&gt;

&lt;p&gt;In &lt;em&gt;React&lt;/em&gt;, Everything other than Effects reruns and Effects are the functions that prevents the execution without there is a change in Dependency Array&lt;/p&gt;

&lt;p&gt;Finally I hope that You understand what &lt;code&gt;useEffect&lt;/code&gt; really does. The Above example is stated as Worst Practice at &lt;a href="https://react.dev/learn/you-might-not-need-an-effect" rel="noopener noreferrer"&gt;You Might Not Need an Effect&lt;/a&gt;. I totally get it. But It's like They are recommending us not to use &lt;code&gt;useEffect&lt;/code&gt; as Effect.&lt;/p&gt;
&lt;h2&gt;
  
  
  Big Lie
&lt;/h2&gt;

&lt;p&gt;It is explained as&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;useEffect is a React Hook that lets you synchronize a component with an external system.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I can't totally get it because The Phrase &lt;em&gt;synchronize with external system&lt;/em&gt; means&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The system's internal state is updated to match the state of the external system.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But in reality, useEffect had nothing to do with that. &lt;code&gt;useSyncExternalStore&lt;/code&gt; does  works in problem with some quirks &lt;em&gt;( Really this problem can't be solved 100%. For now , save that for My Another article )&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;Just think about this facts that &lt;em&gt;React reruns code whenever state changes&lt;/em&gt; and  &lt;em&gt;useEffect is commonly used along with React state&lt;/em&gt;, Then Why do we need to run something based on a state? because always reruns whenever something changes. &lt;/p&gt;

&lt;p&gt;I found a page named as &lt;a href="https://react.dev/learn/synchronizing-with-effects" rel="noopener noreferrer"&gt;Synchronizing with Effects&lt;/a&gt; at React Official Docs which explains about it . At there, They explained that as &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Effects let you run some code after rendering so that you can synchronize your component with some system outside of React.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;From above lines, It is clear that &lt;code&gt;useEffect&lt;/code&gt; lets you write a function which executes after rendering of React.  Then WTF it is named as &lt;code&gt;useEffect&lt;/code&gt;? Does this had any kind of connection with Effect as it's name implies? It's more similar to &lt;code&gt;window.onload&lt;/code&gt; of DOM API. &lt;/p&gt;

&lt;p&gt;I still can't digest the example they gave&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useRef&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;VideoPlayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;isPlaying&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useRef&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isPlaying&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;play&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  &lt;span class="c1"&gt;// Calling these while rendering isn't allowed.&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pause&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Also, this crashes.&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;video&lt;/span&gt; &lt;span class="na"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;loop&lt;/span&gt; &lt;span class="na"&gt;playsInline&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;isPlaying&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setIsPlaying&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setIsPlaying&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;isPlaying&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;isPlaying&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Pause&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Play&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;VideoPlayer&lt;/span&gt;
        &lt;span class="na"&gt;isPlaying&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;isPlaying&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4"&lt;/span&gt;
      &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Here is the reason the error If You try to run it&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Runtime Error
App.js: Cannot read properties of null (reading 'pause') (9:16)

   6 |   if (isPlaying) {
   7 |     ref.current.play();  // Calling these while rendering isn't allowed.
   8 |   } else {
&amp;gt;  9 |     ref.current.pause(); // Also, this crashes.
                       ^
  10 |   }
  11 | 
  12 |   return &amp;lt;video ref={ref} src={src} loop playsInline /&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;They told to us wrap it inside &lt;code&gt;useEffect&lt;/code&gt; to solve this by&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isPlaying&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;play&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pause&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;because &lt;code&gt;ref.current&lt;/code&gt; is set to &lt;code&gt;null&lt;/code&gt; before rendering. But I could solve this by simply changed it to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; if (isPlaying) {
   ref.current?.play();
 } else {
    ref.current?.pause();
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If It's that what they willing to do, They it should be named as &lt;code&gt;onMount&lt;/code&gt; like Vuejs not &lt;code&gt;useEffect&lt;/code&gt; because effects at other library like VueJS, SolidJS really does side effect. &lt;/p&gt;

&lt;p&gt;Here is the explanation They connected the above example with &lt;em&gt;synchronisation&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In this example, The “external system” you synchronized to React state was the browser media API&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Does that really make any sense? I still don't know Why used &lt;em&gt;synchronized&lt;/em&gt; here?. Here Browser Media API is available after First Render So Then Why there is a necessary of Effect here? It's a Sick Example for Effect. I never thought They would explain Effect with Example Code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Another Joke
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Effects let you specify side effects that are caused by rendering itself, rather than by a particular event.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It found this under the title &lt;em&gt;What are Effects and how are they different from events?&lt;/em&gt; and gave above example code for this. After understanding What React really does in name of Effect and reading My Explanation, Could you connect anything?. They gave explanation of Effect of Reactivity System But They did exactly opposite. This is what I always wanted to express to Others&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;I hope You understand What does Effect means? and What React does in name of Effect?. After thinking All this shits, I finally decided to call &lt;code&gt;useEffect&lt;/code&gt;&lt;br&gt;
as &lt;code&gt;usePreventExecution&lt;/code&gt;. I knew that name given by me is sick ;-) . But It is nothing when compares to What They stated about it at Official Documentation. If You found any other suitable name, Let me know at Comments.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
