<?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: Gautam</title>
    <description>The latest articles on DEV Community by Gautam (@gautam_f015817a44372df414).</description>
    <link>https://dev.to/gautam_f015817a44372df414</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%2F4026028%2Fa51e5d1f-b110-4591-89c8-9808cf781251.jpg</url>
      <title>DEV Community: Gautam</title>
      <link>https://dev.to/gautam_f015817a44372df414</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gautam_f015817a44372df414"/>
    <language>en</language>
    <item>
      <title>AI Can Write Your React Code. It Still Can't Tell You Why It's Wrong.</title>
      <dc:creator>Gautam</dc:creator>
      <pubDate>Thu, 16 Jul 2026 07:17:00 +0000</pubDate>
      <link>https://dev.to/gautam_f015817a44372df414/ai-can-write-your-react-code-it-still-cant-tell-you-why-its-wrong-19oc</link>
      <guid>https://dev.to/gautam_f015817a44372df414/ai-can-write-your-react-code-it-still-cant-tell-you-why-its-wrong-19oc</guid>
      <description>&lt;p&gt;Every few months there's a new wave of "AI just made developers obsolete" takes, and every few months React developers specifically get singled out as the easiest to replace — "it's just JSX and hooks, the model's seen a million examples of that." I've been building with React for a while now, and I've been using AI tools daily for just as long. Here's the actual gap nobody talks about, and it's not the one you'd expect.&lt;/p&gt;

&lt;h2&gt;
  
  
  AI is genuinely great at the part everyone worries about
&lt;/h2&gt;

&lt;p&gt;Ask any decent model to write a &lt;strong&gt;&lt;code&gt;useDebounce&lt;/code&gt;&lt;/strong&gt; hook, a controlled form, a memoized list — it'll produce something that looks right, compiles, and probably works for the happy path. That part of the fear is legitimate. The boilerplate-to-competent-code gap has basically closed.&lt;/p&gt;

&lt;h2&gt;
  
  
  The part it's still bad at: telling you &lt;strong&gt;why&lt;/strong&gt; your version is wrong
&lt;/h2&gt;

&lt;p&gt;Here's the thing that doesn't show up in demos. AI-generated code looks confident regardless of whether it's actually correct. It'll happily hand you a &lt;code&gt;useEffect&lt;/code&gt; with a subtly wrong dependency array, a debounce hook that breaks on rapid unmount, a memoized callback that isn't actually stable — and it'll explain the code with the same confident tone whether the explanation is right or completely made up.&lt;/p&gt;

&lt;p&gt;The failure mode isn't "AI can't write React." It's "AI can't reliably tell you when &lt;strong&gt;your&lt;/strong&gt; React is broken, and it can't force you to confront the gap between code that looks plausible and code that's actually correct under real conditions."&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this matters more for React specifically than people think
&lt;/h2&gt;

&lt;p&gt;React bugs are rarely syntax errors. They're timing bugs, stale closures, unstable references causing silent re-renders, cleanup functions that don't run when you assumed they would. None of that shows up by reading the code. It shows up when the code actually runs against real interaction — fast clicks, rapid typing, a component unmounting mid-effect.&lt;/p&gt;

&lt;p&gt;An AI model reading your code can miss all of that, the same way a human skimming a pull request can. The only thing that reliably catches it is running the code against real conditions and checking the actual behavior, not the code's appearance.&lt;/p&gt;

&lt;h2&gt;
  
  
  So what's actually changing for developers
&lt;/h2&gt;

&lt;p&gt;Not "will AI replace you." The real shift is: the value of &lt;em&gt;writing&lt;/em&gt; boilerplate correctly is dropping fast, while the value of &lt;em&gt;knowing whether code is actually correct&lt;/em&gt; — being able to reason about edge cases, verify behavior, and catch what an AI-generated confident explanation glossed over — is going up. If your entire skill was typing out a &lt;code&gt;useEffect&lt;/code&gt; from memory, that's genuinely less valuable now. If your skill is knowing that a debounce hook needs to survive an unmount mid-timer and being able to verify that it does, that's more valuable than ever, because it's exactly the thing AI output doesn't reliably self-check.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practically, this means practicing differently
&lt;/h2&gt;

&lt;p&gt;Reading AI-generated React code and nodding along teaches you nothing about whether you could catch the same bug yourself. The instinct that actually matters — spotting a stale closure, knowing when a dependency array is wrong, recognizing an unstable reference — only builds by writing code yourself and getting real, immediate feedback on whether it's actually correct, not whether it looks correct.&lt;/p&gt;

&lt;p&gt;This is part of why I built &lt;strong&gt;&lt;a href="https://www.reactgrind.com" rel="noopener noreferrer"&gt;ReactGrind&lt;/a&gt;&lt;/strong&gt; — React-specific coding challenges checked by real automated test suites instead of a written answer key. The whole point is closing that exact gap: you write the component, real tests mount it and interact with it the way a user actually would, and you find out immediately whether it holds up — not whether it merely resembles a correct answer.&lt;/p&gt;

&lt;p&gt;AI can write plausible React code all day. Practicing against real tests is still how you build the instinct to know the difference.&lt;/p&gt;




&lt;p&gt;Curious what others are seeing here — has your day-to-day debugging shifted at all now that AI writes a bigger share of first-draft code? What's actually catching the bugs for you these days?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>I built a LeetCode-style platform, but for only for React (not DSA)</title>
      <dc:creator>Gautam</dc:creator>
      <pubDate>Tue, 14 Jul 2026 23:15:10 +0000</pubDate>
      <link>https://dev.to/gautam_f015817a44372df414/i-built-a-leetcode-style-platform-but-for-only-for-react-not-dsa-1ccj</link>
      <guid>https://dev.to/gautam_f015817a44372df414/i-built-a-leetcode-style-platform-but-for-only-for-react-not-dsa-1ccj</guid>
      <description>&lt;p&gt;If you've ever prepped for a &lt;strong&gt;frontend interview&lt;/strong&gt;, you've probably hit this weird gap: LeetCode will happily grill you on binary trees and dynamic programming, but it has almost nothing to say about the thing you'll actually be asked to build in a real frontend interview — a debounced search box, a modal that traps focus correctly, a component that doesn't quietly re-render itself into a performance problem.&lt;/p&gt;

&lt;p&gt;That gap is why I built &lt;a href="https://www.reactgrind.com/" rel="noopener noreferrer"&gt;ReactGrind&lt;/a&gt;.&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%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz2gydny4roxo8pdfynxq.png" 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%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz2gydny4roxo8pdfynxq.png" alt="React Coding Challenges" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What ReactGrind actually is?
&lt;/h2&gt;

&lt;p&gt;ReactGrind is a coding practice platform built specifically around React — not algorithms, not data structures, just the actual behavior of React itself: hooks, rendering, state, effects, memoization, and the kind of edge cases that only show up once real user interaction is involved.&lt;/p&gt;

&lt;p&gt;Every challenge comes with a real automated test suite, not a static answer key. You write a component, hit run, and the tests mount it, click it, type into it, and check the result — the same way a real pull request gets reviewed before it ships. If it passes, you know it actually works. If it fails, you know exactly where.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's on there right now
&lt;/h2&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%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnkcewpem42qvt5iw33mw.png" 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%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnkcewpem42qvt5iw33mw.png" alt="Practice React Online - ReactGrind" width="799" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.reactgrind.com/problems" rel="noopener noreferrer"&gt;50+ problems&lt;/a&gt;&lt;/strong&gt; (adding questions daily) across Hooks &amp;amp; State, Custom Hooks, Performance, Context &amp;amp; Patterns, Forms &amp;amp; Events, and a FAANG-style Interview Set&lt;br&gt;
A React Interview Prep section — 200+ questions with plain-English explanations, analogies, and code examples, not just one-line definitions&lt;br&gt;
A free online React compiler/playground — no signup, no setup, just write and run React code instantly in the browser&lt;br&gt;
A blog covering practical React engineering topics — React 19's actual production impact, MERN stack interview prep, and things like whether React counts as frontend or backend (yes, people really do ask that)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why test-based practice, specifically?&lt;/strong&gt;&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%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fp2bt8v4gs6799d3bil8x.png" 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%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fp2bt8v4gs6799d3bil8x.png" alt="React coding challenges - ReactGrind" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Writing a debounced search box is easy. Writing one that still works when someone types fast, deletes everything mid-debounce, or unmounts the component while a timer is pending — that's the part that actually gets caught in code review, and it's the part a written answer key can't check for you. A real test suite catches it immediately, which is a much better habit to build than comparing your code to someone else's "correct" solution and hoping it's equivalent.&lt;/p&gt;

&lt;p&gt;If you're prepping for a &lt;strong&gt;frontend role&lt;/strong&gt;, or you just want to stay sharp on React outside of whatever you're building at work, it's free to start: reactgrind.com&lt;/p&gt;

&lt;p&gt;Since this is early and actively evolving — if you try it and something feels off, missing, or like it should exist but doesn't, I'd genuinely like to hear it. Bug reports, feature ideas, "this problem's test cases are wrong," all of it is useful right now.&lt;/p&gt;

</description>
      <category>react</category>
      <category>mern</category>
      <category>leetcode</category>
      <category>java</category>
    </item>
    <item>
      <title>10 React Hooks Interview Questions That Actually Trip People Up (With Explanations)</title>
      <dc:creator>Gautam</dc:creator>
      <pubDate>Sun, 12 Jul 2026 12:42:05 +0000</pubDate>
      <link>https://dev.to/gautam_f015817a44372df414/10-react-hooks-interview-questions-that-actually-trip-people-up-with-explanations-2d3g</link>
      <guid>https://dev.to/gautam_f015817a44372df414/10-react-hooks-interview-questions-that-actually-trip-people-up-with-explanations-2d3g</guid>
      <description>&lt;p&gt;If you've been prepping for &lt;strong&gt;React interviews&lt;/strong&gt;, you've probably noticed most &lt;em&gt;interview question&lt;/em&gt; lists online are either too basic (what is useState) or copy-pasted from the same five articles. So I put together a list of &lt;strong&gt;hooks questions&lt;/strong&gt; that come up often in real interviews — the kind that sound simple but expose whether you actually understand what's happening under the hood.&lt;/p&gt;

&lt;p&gt;Let's go through them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why does this useEffect cause an infinite loop?
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Counter&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;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCount&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;0&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="nf"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&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;count&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Answer: No &lt;strong&gt;dependency array&lt;/strong&gt; means the effect runs after every render.&lt;br&gt;
Since it updates state on every run, it triggers another render, which&lt;br&gt;
triggers the effect again — forever. Add &lt;strong&gt;[]&lt;/strong&gt; if you want it to run once, or a proper dependency array if it should run on specific value changes.&lt;/p&gt;

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

&lt;p&gt;Both cache something between renders, but:&lt;/p&gt;

&lt;p&gt;**useMemo **caches a value (the result of a computation)&lt;br&gt;
**useCallback **caches a function reference&lt;/p&gt;

&lt;p&gt;A common gotcha: useCallback(fn, deps) is literally equivalent to&lt;br&gt;
useMemo(() =&amp;gt; fn, deps). If you understand that, you understand both.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why does my state update not reflect immediately after setState?
&lt;/h2&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;Aman&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;handleClick&lt;/span&gt;&lt;span class="p"&gt;()&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;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;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;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// still logs "Aman"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Answer: State updates are **asynchronous **and batched. name inside&lt;br&gt;
handleClick is a snapshot from the current render's closure — it won't&lt;br&gt;
reflect the update until the component re-renders.&lt;/p&gt;

&lt;h2&gt;
  
  
  What problem does **useRef **solve that **useState **can't?
&lt;/h2&gt;

&lt;p&gt;useRef gives you a mutable object that persists across renders without&lt;br&gt;
triggering a re-render when it changes. Great for:&lt;/p&gt;

&lt;p&gt;Storing a DOM node reference&lt;br&gt;
Keeping a mutable value (like a timer ID) that shouldn't cause a re-render&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do &lt;strong&gt;custom hooks&lt;/strong&gt; need to start with "use"?
&lt;/h2&gt;

&lt;p&gt;It's not just convention — it's how React's linter (and React itself) knows to apply the Rules of Hooks (no conditional calls, no calls inside loops) to your custom hook. Name it getSomething instead of useSomething and &lt;strong&gt;ESLint's&lt;/strong&gt; hooks plugin won't catch violations inside it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's a stale closure, and how does it happen with hooks?
&lt;/h2&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;interval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;setInterval&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="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// always logs the initial value&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;1000&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;clearInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;interval&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;Answer: The effect's closure captures count from the render it was&lt;br&gt;
created in. With an empty dependency array, that closure never updates —&lt;br&gt;
so count is frozen at its initial value forever inside the interval.&lt;/p&gt;

&lt;h2&gt;
  
  
  When would you use &lt;strong&gt;useLayoutEffect **instead of **useEffect&lt;/strong&gt;?
&lt;/h2&gt;

&lt;p&gt;Answer: useLayoutEffect runs synchronously before the browser paints. Use it when you need to measure or mutate the DOM before the user sees anything (e.g., preventing a visual flicker when adjusting an element's position). useEffect runs after paint, which is fine for most side effects (data fetching, subscriptions).&lt;/p&gt;

&lt;h2&gt;
  
  
  Can you conditionally call a hook?
&lt;/h2&gt;

&lt;p&gt;No — and interviewers love asking why, not just that. React tracks hooks&lt;br&gt;
by call order per render, not by name. If a hook is skipped in one render&lt;br&gt;
and called in another, the entire hook-state mapping shifts, causing bugs&lt;br&gt;
that are hard to trace.&lt;/p&gt;

&lt;h2&gt;
  
  
  What does the dependency array in &lt;strong&gt;useEffect&lt;/strong&gt; actually compare?
&lt;/h2&gt;

&lt;p&gt;Shallow equality (Object.is), not deep equality. This is why passing an&lt;br&gt;
object or array literal as a dependency causes the effect to run on every&lt;br&gt;
render — a new reference is created every time, even if the contents are&lt;br&gt;
identical.&lt;/p&gt;

&lt;h2&gt;
  
  
  How would you **debounce **a search input using hooks?
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;useDebounce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;delay&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;debounced&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setDebounced&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="nx"&gt;value&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;timer&lt;/span&gt; &lt;span class="o"&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="nf"&gt;setDebounced&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;delay&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;clearTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timer&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;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;debounced&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;The &lt;strong&gt;cleanup function&lt;/strong&gt; is the key part — it cancels the previous timer&lt;br&gt;
whenever value changes before the delay finishes, so only the last&lt;br&gt;
keystroke actually triggers the debounced update.&lt;/p&gt;

&lt;p&gt;If you want to test yourself on questions like these interactively (with&lt;br&gt;
instant feedback instead of just reading answers), I've been building&lt;br&gt;
&lt;a href="//www.reactgrind.com"&gt;ReactGrind &lt;/a&gt; — a LeetCode-style platform specifically&lt;br&gt;
for React.js practice. Still actively adding new challenges, so &lt;strong&gt;feedback&lt;/strong&gt; is very welcome if you try it out.&lt;/p&gt;

&lt;p&gt;What's a hooks question that stumped you in an interview? Drop it in the&lt;br&gt;
comments — might turn it into a follow-up post.&lt;/p&gt;

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