<?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: Aanand</title>
    <description>The latest articles on DEV Community by Aanand (@aanand_4d81b59bb2a50beb70).</description>
    <link>https://dev.to/aanand_4d81b59bb2a50beb70</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%2F3538852%2F9486fe8d-b7ef-40db-8c99-7ebbaf3e6d6b.jpg</url>
      <title>DEV Community: Aanand</title>
      <link>https://dev.to/aanand_4d81b59bb2a50beb70</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aanand_4d81b59bb2a50beb70"/>
    <language>en</language>
    <item>
      <title>useEffect hook Simple and accurate explanation</title>
      <dc:creator>Aanand</dc:creator>
      <pubDate>Mon, 27 Apr 2026 12:08:10 +0000</pubDate>
      <link>https://dev.to/aanand_4d81b59bb2a50beb70/useeffect-hook-simple-and-accurate-explanation-30bl</link>
      <guid>https://dev.to/aanand_4d81b59bb2a50beb70/useeffect-hook-simple-and-accurate-explanation-30bl</guid>
      <description>&lt;p&gt;React has one job:&lt;br&gt;
👉 Take &lt;strong&gt;data&lt;/strong&gt; → show &lt;strong&gt;UI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But real apps need more than just &lt;strong&gt;showing UI&lt;/strong&gt;. You also need to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;fetch data from APIs&lt;/li&gt;
&lt;li&gt;set timers&lt;/li&gt;
&lt;li&gt;store data&lt;/li&gt;
&lt;li&gt;listen to events&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These things are outside React’s job.&lt;/p&gt;

&lt;p&gt;So &lt;strong&gt;useEffect&lt;/strong&gt; lets you run code after React updates the screen, especially for things outside React.&lt;/p&gt;

&lt;p&gt;👉 React &lt;strong&gt;&lt;em&gt;renders UI&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
👉 Then useEffect runs &lt;strong&gt;&lt;em&gt;side work&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  ⚠️ The part most people miss (important)
&lt;/h2&gt;

&lt;p&gt;useEffect is not just “run after render”&lt;/p&gt;

&lt;p&gt;It’s: “Run after render — but only when something changes (if you tell it what to watch)”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The 3 real behaviors&lt;/strong&gt; (this is where clarity comes)&lt;/p&gt;

&lt;p&gt;1.Run every time (&lt;strong&gt;default&lt;/strong&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="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;Runs after every render&lt;/span&gt;&lt;span class="dl"&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;👉 &lt;em&gt;No control → runs again and again&lt;/em&gt;&lt;br&gt;
👉 Usually a bad idea&lt;/p&gt;

&lt;p&gt;2.Run only once (&lt;strong&gt;on mount&lt;/strong&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="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;Runs only once&lt;/span&gt;&lt;span class="dl"&gt;"&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;👉 Like: “Do this when the &lt;em&gt;page loads&lt;/em&gt;”&lt;/p&gt;

&lt;p&gt;3.Run when &lt;strong&gt;something changes&lt;/strong&gt; (MOST IMPORTANT)&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="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;Runs when count changes&lt;/span&gt;&lt;span class="dl"&gt;"&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;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;👉 “Only run when count &lt;em&gt;changes&lt;/em&gt;”&lt;/p&gt;

</description>
      <category>react</category>
      <category>frontend</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How your compiler finds the data that is stored inside the variable (Symbol table)</title>
      <dc:creator>Aanand</dc:creator>
      <pubDate>Mon, 27 Oct 2025 05:18:59 +0000</pubDate>
      <link>https://dev.to/aanand_4d81b59bb2a50beb70/how-your-compiler-finds-the-data-that-is-stored-inside-the-variable-symbol-table-48c6</link>
      <guid>https://dev.to/aanand_4d81b59bb2a50beb70/how-your-compiler-finds-the-data-that-is-stored-inside-the-variable-symbol-table-48c6</guid>
      <description>&lt;p&gt;Have you ever typed &lt;em&gt;print(variable_name)&lt;/em&gt; and wondered how your compiler actually finds the data by using variable name? It's like magic, but there's a fascinating process working behind the scenes!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Variables are like house Addresses&lt;/strong&gt;&lt;br&gt;
Think of computer memory like a giant apartment building with millions of rooms. Each room has a number address like "Room #0x1000.&lt;/p&gt;

&lt;p&gt;when you write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int num = 37;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's what happens:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Find an empty room:&lt;/strong&gt; The compiler finds an available memory location (say, room #0x1000)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Move in the value:&lt;/strong&gt; The number 37 moves into this room.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Put up a name tag:&lt;/strong&gt; The variable name "num" becomes the friendly name for this address.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;The Compiler's Secret Address Book&lt;/strong&gt;&lt;br&gt;
So when your program actually runs, all those name tags disappear! how does&lt;br&gt;
&lt;em&gt;&lt;strong&gt;cout &amp;lt;&amp;lt; num&lt;/strong&gt;&lt;/em&gt; still work?&lt;br&gt;
The compiler keeps a secret address book called a symbol table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌────────────┬──────────────────┐
│ Variable   │ Memory Address   │
├────────────┼──────────────────┤
│ num        │ 0x1000           │
│ age        │ 0x1004           │
│ name       │ 0x2000           │
└────────────┴──────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you print a variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cout &amp;lt;&amp;lt; num;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The compiler:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Looks up "num" in its address book&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finds it lives at memory address 0x1000&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Sends instructions: "Go to address 0x1000 and print what's inside!"&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Variable names are for humans — memory addresses are for compiler!&lt;/p&gt;

</description>
      <category>c</category>
      <category>cpp</category>
      <category>programming</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
