<?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: Tarun Sharma</title>
    <description>The latest articles on DEV Community by Tarun Sharma (@101beardo).</description>
    <link>https://dev.to/101beardo</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4074008%2F83b63d19-4973-412d-bc59-b836ea597026.jpg</url>
      <title>DEV Community: Tarun Sharma</title>
      <link>https://dev.to/101beardo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/101beardo"/>
    <language>en</language>
    <item>
      <title>5 React interview questions I'd actually ask (and how I'd answer them)</title>
      <dc:creator>Tarun Sharma</dc:creator>
      <pubDate>Fri, 14 Aug 2026 08:26:33 +0000</pubDate>
      <link>https://dev.to/101beardo/5-react-interview-questions-id-actually-ask-and-how-id-answer-them-3422</link>
      <guid>https://dev.to/101beardo/5-react-interview-questions-id-actually-ask-and-how-id-answer-them-3422</guid>
      <description>&lt;p&gt;Most "React interview questions" lists online are either trivia (define useEffect) or so advanced they're not useful below 3-4 years of experience. Here are 5 I think are actually worth knowing, with the answer I'd give if asked.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. What does this log, and why?
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;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="nx"&gt;i&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;It logs &lt;code&gt;3, 3, 3&lt;/code&gt;. &lt;code&gt;var&lt;/code&gt; gives the whole loop one shared variable, so by the time the callbacks run, the loop has already finished and &lt;code&gt;i&lt;/code&gt; is 3. Swap &lt;code&gt;var&lt;/code&gt; for &lt;code&gt;let&lt;/code&gt; and it logs &lt;code&gt;0, 1, 2&lt;/code&gt;, &lt;code&gt;let&lt;/code&gt; creates a fresh binding for every iteration, so each callback closes over its own copy.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Why doesn't an empty dependency array guarantee no stale-closure bugs?
&lt;/h2&gt;

&lt;p&gt;An effect with &lt;code&gt;[]&lt;/code&gt; only runs once, but any function or state it references from the render it was created in is frozen at that value forever, that's a stale closure. It's the same mechanism as question 1, just applied to a React render instead of a loop iteration.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. What's the actual difference between useMemo and useCallback?
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;useCallback(fn, deps)&lt;/code&gt; is just &lt;code&gt;useMemo(() =&amp;gt; fn, deps)&lt;/code&gt;. One memoizes a value, the other memoizes a function reference. People treat them as separate concepts when one is a special case of the other.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Why can a sibling component re-render even though its own props didn't change?
&lt;/h2&gt;

&lt;p&gt;Because React re-renders every child of a component that re-renders, by default, regardless of whether that specific child's props changed. &lt;code&gt;React.memo&lt;/code&gt; is what actually stops it, re-rendering isn't opt-out at the parent level, it's opt-in per child.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. What does the virtual DOM actually skip?
&lt;/h2&gt;

&lt;p&gt;It skips DOM writes, not DOM reads or re-renders. React still runs your component function and builds a new tree every render; the virtual DOM diff is what decides which actual DOM mutations are necessary, which are usually the expensive part.&lt;/p&gt;

&lt;p&gt;What would you add to this list?&lt;/p&gt;

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