<?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: ReactChallenges</title>
    <description>The latest articles on DEV Community by ReactChallenges (@reactchallenges).</description>
    <link>https://dev.to/reactchallenges</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%2F854942%2Fe450946a-3098-4715-8d06-0892ab9ac221.png</url>
      <title>DEV Community: ReactChallenges</title>
      <link>https://dev.to/reactchallenges</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/reactchallenges"/>
    <language>en</language>
    <item>
      <title>Cognitive surrender: the 15-minute habit that keeps your brain in the loop</title>
      <dc:creator>ReactChallenges</dc:creator>
      <pubDate>Thu, 12 Nov 2026 10:42:56 +0000</pubDate>
      <link>https://dev.to/reactchallenges/cognitive-surrender-the-15-minute-habit-that-keeps-your-brain-in-the-loop-42k5</link>
      <guid>https://dev.to/reactchallenges/cognitive-surrender-the-15-minute-habit-that-keeps-your-brain-in-the-loop-42k5</guid>
      <description>&lt;p&gt;The fastest way to ship code right now is to describe a problem to an AI and paste the answer. The fastest way to forget how to solve problems is to do it every time.&lt;/p&gt;

&lt;p&gt;AI is not the enemy. The enemy is the reflex.&lt;/p&gt;

&lt;h2&gt;
  
  
  The quiet trade behind every prompt
&lt;/h2&gt;

&lt;p&gt;Ask AI to explain the error. Ask AI to write the function. Ask AI to name the variable and review the PR. Each request saves minutes. Together, they can remove the part of the work that used to build judgment.&lt;/p&gt;

&lt;p&gt;Cognitive surrender is what happens when we hand over more than the typing. We hand over the model of the problem: the attempt to decompose it, the edge case we almost missed, the bug we had to trace.&lt;/p&gt;

&lt;p&gt;It feels efficient because the output is usually fine. That's exactly why it's easy to miss the cost. Fine output hides the missing rep.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why 15 minutes is enough
&lt;/h2&gt;

&lt;p&gt;Skill comes from retrieval and struggle, not from watching answers appear. You need a loop where you read the problem, form a plan, write code, and test it — without outsourcing the first three steps.&lt;/p&gt;

&lt;p&gt;Fifteen minutes is short enough to do daily and long enough to complete that loop. Even on an easy kata.&lt;/p&gt;

&lt;h2&gt;
  
  
  A protocol that doesn't cheat
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Read the problem twice. Write the input, output, and one edge case in plain words.&lt;/li&gt;
&lt;li&gt;Draft the steps before touching the editor.&lt;/li&gt;
&lt;li&gt;Set a 15-minute timer. Solve without AI.&lt;/li&gt;
&lt;li&gt;If you get stuck, write down exactly where the plan breaks.&lt;/li&gt;
&lt;li&gt;Only then compare with the solution or ask AI.&lt;/li&gt;
&lt;li&gt;Save one takeaway: the trick, the edge case, or the bug.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The rule: no prompts until you have a plan. The comparison is where AI is most useful — after you have something to compare.&lt;/p&gt;

&lt;h2&gt;
  
  
  8 free katas to start (10 minutes each)
&lt;/h2&gt;

&lt;p&gt;All of these are free and available in JavaScript, TypeScript, and Python.&lt;/p&gt;

&lt;h3&gt;
  
  
  Strings
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.reactchallenges.com/katas/valid-palindrome" rel="noopener noreferrer"&gt;Valid Palindrome&lt;/a&gt; — normalize the input, then compare from both ends.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.reactchallenges.com/katas/is-anagram" rel="noopener noreferrer"&gt;Is Anagram&lt;/a&gt; — count letters and compare frequencies.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.reactchallenges.com/katas/max-distance" rel="noopener noreferrer"&gt;Max Distance&lt;/a&gt; — parse movement commands and decide when &lt;code&gt;*&lt;/code&gt; helps.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Arrays
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.reactchallenges.com/katas/merge-intervals" rel="noopener noreferrer"&gt;Merge Intervals&lt;/a&gt; — sort by start, then merge overlaps.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.reactchallenges.com/katas/find-first-repeated" rel="noopener noreferrer"&gt;Find First Repeated Element&lt;/a&gt; — track seen values in one pass.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.reactchallenges.com/katas/unique-sorted" rel="noopener noreferrer"&gt;Unique Sorted&lt;/a&gt; — dedupe, then order.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Objects and recursion
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.reactchallenges.com/katas/organize-by-category" rel="noopener noreferrer"&gt;Organize by Category&lt;/a&gt; — group with reduce and sum quantities.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.reactchallenges.com/katas/tree-height" rel="noopener noreferrer"&gt;Tree Height&lt;/a&gt; — one recursive call per branch.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When 10 minutes feels easy
&lt;/h2&gt;

&lt;p&gt;Add one of these:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.reactchallenges.com/katas/flatten-array" rel="noopener noreferrer"&gt;Flatten Array&lt;/a&gt; — recursion over nested data.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.reactchallenges.com/katas/decode-parentheses" rel="noopener noreferrer"&gt;Decode Parentheses&lt;/a&gt; — stack-based parsing.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.reactchallenges.com/katas/max-non-adjacent-sum" rel="noopener noreferrer"&gt;Max Non-Adjacent Sum&lt;/a&gt; — dynamic programming with memoization.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The point is not the algorithm
&lt;/h2&gt;

&lt;p&gt;You are not trying to become a competitive programmer. You are trying to keep the loop: read, reason, write, verify.&lt;/p&gt;

&lt;p&gt;AI amplifies whatever you bring to it. If you bring a sharp model of the problem, it amplifies that. If you bring nothing, it replaces that too.&lt;/p&gt;

&lt;p&gt;Fifteen minutes a day is a small price to stay in the loop.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.reactchallenges.com/katas" rel="noopener noreferrer"&gt;🔥 Start with a 10-minute kata&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>python</category>
      <category>ai</category>
    </item>
    <item>
      <title>🚀 New React Challenge: Nested Comments</title>
      <dc:creator>ReactChallenges</dc:creator>
      <pubDate>Wed, 11 Nov 2026 11:31:22 +0000</pubDate>
      <link>https://dev.to/reactchallenges/new-react-challenge-nested-comments-9fm</link>
      <guid>https://dev.to/reactchallenges/new-react-challenge-nested-comments-9fm</guid>
      <description>&lt;p&gt;Flattening a comment thread into a single array works until you need to reply to a reply. Then you're faking depth with parent ids, and every edit or delete means rebuilding the whole list. A recursive tree keeps the shape of the conversation and lets you update just the branch that changed.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧩 Overview
&lt;/h2&gt;

&lt;p&gt;Build a threaded comments UI: render a recursive thread, then reply, edit, collapse, and delete nodes while every update returns a new tree instead of mutating the seed.&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://www.reactchallenges.com/challenges/nested-comments" rel="noopener noreferrer"&gt;https://www.reactchallenges.com/challenges/nested-comments&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  ✅ Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Render the full thread from &lt;code&gt;initialComments&lt;/code&gt;, with replies nested inside their parent.&lt;/li&gt;
&lt;li&gt;Each comment shows its author and text, and exposes reply, edit, and delete controls.&lt;/li&gt;
&lt;li&gt;Comments with replies get a collapse control with &lt;code&gt;aria-expanded&lt;/code&gt; that hides or shows only their replies.&lt;/li&gt;
&lt;li&gt;Replying opens a form, appends a trimmed reply authored by "You", and closes it. Empty or whitespace-only text is rejected and the form stays open.&lt;/li&gt;
&lt;li&gt;Editing opens a prefilled editor, saves a trimmed update to that comment only, or cancels to restore the original text.&lt;/li&gt;
&lt;li&gt;Deleting removes the comment and its entire subtree, leaving siblings intact.&lt;/li&gt;
&lt;li&gt;Deleting every comment renders an empty state.&lt;/li&gt;
&lt;li&gt;All updates are immutable: neither the seed tree nor any &lt;code&gt;replies&lt;/code&gt; array is mutated.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💡 Notes
&lt;/h2&gt;

&lt;p&gt;The core idea is a recursive tree update. Map the current level, recurse into &lt;code&gt;replies&lt;/code&gt; when the target isn't the current node, and rebuild only the nodes on that path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;updateComment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;comments&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Comment&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="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;update&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Comment&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Comment&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="nc"&gt;Comment&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="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;comments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="n"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;
      &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;comment&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="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;replies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;updateComment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;replies&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;update&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="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;Reply and edit both reuse it: one callback appends a reply, the other returns &lt;code&gt;{ ...comment, text }&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Collapse is UI state, not tree data. Keep the collapsed ids in a &lt;code&gt;Set&lt;/code&gt; and let rendering hide the replies, so the branch still exists in the tree.&lt;/p&gt;

&lt;p&gt;Delete is the same walk with &lt;code&gt;filter&lt;/code&gt; instead of &lt;code&gt;map&lt;/code&gt;, which removes the whole subtree in one pass.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧪 Tests
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;renders all seed comments with replies nested under their parent&lt;/li&gt;
&lt;li&gt;shows the author and text of every comment&lt;/li&gt;
&lt;li&gt;collapses a comment's replies and keeps the comment visible&lt;/li&gt;
&lt;li&gt;expands a collapsed comment again&lt;/li&gt;
&lt;li&gt;opens the reply form under the correct comment&lt;/li&gt;
&lt;li&gt;adds a reply with the author You and closes the form&lt;/li&gt;
&lt;li&gt;rejects an empty or whitespace-only reply and keeps the form open&lt;/li&gt;
&lt;li&gt;prefills the editor with the current comment text&lt;/li&gt;
&lt;li&gt;saves an edited comment and closes the editor&lt;/li&gt;
&lt;li&gt;cancels an edit and restores the original text&lt;/li&gt;
&lt;li&gt;deletes a comment and its replies, keeping siblings intact&lt;/li&gt;
&lt;li&gt;shows the empty state when every comment is deleted&lt;/li&gt;
&lt;li&gt;never mutates the imported seed tree&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;Once you can update a nested comment thread immutably, you can apply the same helper to file explorers, menus, org charts, and nested settings. That's the skill this challenge gives you: thinking in trees instead of flat lists.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.reactchallenges.com/challenges/nested-comments" rel="noopener noreferrer"&gt;🔥 Start the Challenge Now&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>typescript</category>
    </item>
    <item>
      <title>🚀 New React Challenge: Collaborative Editor</title>
      <dc:creator>ReactChallenges</dc:creator>
      <pubDate>Wed, 04 Nov 2026 11:42:57 +0000</pubDate>
      <link>https://dev.to/reactchallenges/new-react-challenge-collaborative-editor-1kdk</link>
      <guid>https://dev.to/reactchallenges/new-react-challenge-collaborative-editor-1kdk</guid>
      <description>&lt;p&gt;Most editors keep the truth in local state and hope that the save, a second tab, and a remote collaborator all agree. This challenge inverts that: every change is an immutable event appended to a log, and the document you see is just a projection of it.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧩 Overview
&lt;/h2&gt;

&lt;p&gt;Build a collaborative notes editor as a tiny event-sourced + CQRS system. Edits are optimistic, the document is rebuilt from the event log, autosave debounces into a single request, and a simulated peer merges its events through the same rules.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.reactchallenges.com/challenges/collaborative-editor" rel="noopener noreferrer"&gt;https://www.reactchallenges.com/challenges/collaborative-editor&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  ✅ Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Implement the editor in &lt;code&gt;App.tsx&lt;/code&gt;; the provided &lt;code&gt;types.ts&lt;/code&gt;, &lt;code&gt;data.ts&lt;/code&gt;, &lt;code&gt;eventLog.ts&lt;/code&gt;, &lt;code&gt;projection.ts&lt;/code&gt;, &lt;code&gt;api.ts&lt;/code&gt;, and &lt;code&gt;peer.ts&lt;/code&gt; are read-only, and the first render shows the document built from &lt;code&gt;initialEvents&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Render one editable block per textarea in insertion order, with an &lt;code&gt;aria-label&lt;/code&gt; on each; the seed blocks appear in that order.&lt;/li&gt;
&lt;li&gt;Each block has a delete control that removes the block immediately.&lt;/li&gt;
&lt;li&gt;An add control appends a new empty block to the end of the document.&lt;/li&gt;
&lt;li&gt;Typing updates the visible text immediately and sets the save status to &lt;code&gt;Dirty&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Several edits in quick succession result in a single save, not one save per keystroke.&lt;/li&gt;
&lt;li&gt;While a save is pending the status reads &lt;code&gt;Saving…&lt;/code&gt;; after a successful save it reads &lt;code&gt;Saved&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;When a save fails the status reads &lt;code&gt;Error&lt;/code&gt;, the edited text stays visible, and a retry control appears.&lt;/li&gt;
&lt;li&gt;Clicking retry saves the latest document immediately and moves from &lt;code&gt;Saving…&lt;/code&gt; to &lt;code&gt;Saved&lt;/code&gt; on success.&lt;/li&gt;
&lt;li&gt;A pending autosave is cancelled on unmount, so leaving the editor does not start a save.&lt;/li&gt;
&lt;li&gt;A remote update applied to a block replaces that block's text with the remote text.&lt;/li&gt;
&lt;li&gt;A remote event that was already applied is ignored: it changes nothing and triggers no extra save.&lt;/li&gt;
&lt;li&gt;A remote event that is older than the block's current version is ignored.&lt;/li&gt;
&lt;li&gt;Remote edits never mark the document &lt;code&gt;Dirty&lt;/code&gt; and never trigger an autosave.&lt;/li&gt;
&lt;li&gt;The presence indicator reads &lt;code&gt;Ana is editing&lt;/code&gt; while the simulated peer subscription is active; on unmount the subscription is removed and the peer reports no listeners.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💡 Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Treat the log as append-only and always return a new array from an append — mutate &lt;code&gt;events&lt;/code&gt; in place and React never re-renders.&lt;/li&gt;
&lt;li&gt;Idempotency is keyed on the event &lt;code&gt;id&lt;/code&gt;, not its payload: a re-delivered event can carry a higher version and still has to be dropped before it reaches the projection.&lt;/li&gt;
&lt;li&gt;Debounce the save with the timeout handle in a ref, reset it on every edit, and clear it in the effect cleanup so an unmount never fires a pending save.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧪 Tests
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Renders the three initial blocks in order&lt;/li&gt;
&lt;li&gt;Updates the text immediately and marks the status dirty&lt;/li&gt;
&lt;li&gt;Debounces a burst of edits into a single save&lt;/li&gt;
&lt;li&gt;Moves from saving to saved and persists the latest text&lt;/li&gt;
&lt;li&gt;Keeps the edited text on failure and lets retry save the latest version&lt;/li&gt;
&lt;li&gt;Removes a block immediately when it is deleted&lt;/li&gt;
&lt;li&gt;Adds a new empty block&lt;/li&gt;
&lt;li&gt;Applies a remote update with a higher version&lt;/li&gt;
&lt;li&gt;Ignores a remote event whose id was already applied&lt;/li&gt;
&lt;li&gt;Ignores a stale remote event with a lower version&lt;/li&gt;
&lt;li&gt;Shows the peer presence and unsubscribes on unmount&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;You finish with a mental model you can reuse anywhere state has to be synced: derive the read model, write events instead of mutating objects, and make every incoming change idempotent. That's the shape of most real-time collaboration and offline-first code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.reactchallenges.com/challenges/collaborative-editor" rel="noopener noreferrer"&gt;🔥 Start the Challenge Now&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>frontendchallenge</category>
    </item>
    <item>
      <title>🚀 New React Challenge: Build an External Store</title>
      <dc:creator>ReactChallenges</dc:creator>
      <pubDate>Wed, 28 Oct 2026 12:50:18 +0000</pubDate>
      <link>https://dev.to/reactchallenges/new-react-challenge-build-an-external-store-48n9</link>
      <guid>https://dev.to/reactchallenges/new-react-challenge-build-an-external-store-48n9</guid>
      <description>&lt;p&gt;Most React apps reach for a state library the moment state has to live outside a component. Building one yourself is the fastest way to understand what &lt;code&gt;useSyncExternalStore&lt;/code&gt; actually expects — and why a store that returns a fresh object on every &lt;code&gt;getSnapshot&lt;/code&gt; call loops forever.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧩 Overview
&lt;/h2&gt;

&lt;p&gt;Build the external store behind a live metrics dashboard: immutable snapshots, &lt;code&gt;subscribe&lt;/code&gt;/&lt;code&gt;getSnapshot&lt;/code&gt;, five-second polling, stale-response protection, and pause/resume with real cleanup — all in &lt;code&gt;store.ts&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://www.reactchallenges.com/challenges/build-external-store" rel="noopener noreferrer"&gt;https://www.reactchallenges.com/challenges/build-external-store&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  ✅ Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;createMetricsStore(fetcher)&lt;/code&gt; returns &lt;code&gt;subscribe&lt;/code&gt;, &lt;code&gt;getSnapshot&lt;/code&gt;, &lt;code&gt;start&lt;/code&gt;, &lt;code&gt;refresh&lt;/code&gt;, &lt;code&gt;pause&lt;/code&gt;, and &lt;code&gt;resume&lt;/code&gt;; &lt;code&gt;fetcher&lt;/code&gt; defaults to &lt;code&gt;fetchMetrics&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The initial snapshot is &lt;code&gt;{ metrics: [], updatedAt: null, status: "idle", error: null }&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;getSnapshot&lt;/code&gt; returns the same object reference until the state changes.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;subscribe(listener)&lt;/code&gt; registers a listener and returns a function that removes it.&lt;/li&gt;
&lt;li&gt;Subscribers are notified after every state change.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;start()&lt;/code&gt; fetches immediately, then every five seconds, and returns a cleanup that stops polling.&lt;/li&gt;
&lt;li&gt;Calling &lt;code&gt;start()&lt;/code&gt; while polling is active does not create a second interval or another fetch.&lt;/li&gt;
&lt;li&gt;While a request is in flight and the store is not paused, the status is &lt;code&gt;loading&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;refresh()&lt;/code&gt; ends in &lt;code&gt;live&lt;/code&gt; with the new metrics and &lt;code&gt;updatedAt&lt;/code&gt;, or in &lt;code&gt;error&lt;/code&gt; with the message.&lt;/li&gt;
&lt;li&gt;When a request fails, the last successful metrics stay in the snapshot.&lt;/li&gt;
&lt;li&gt;After an error, the next poll retries the request.&lt;/li&gt;
&lt;li&gt;When two requests overlap, only the latest response is applied.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pause()&lt;/code&gt; stops polling, sets the status to &lt;code&gt;paused&lt;/code&gt;, and ignores an in-flight response.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;resume()&lt;/code&gt; fetches immediately, restarts polling, and does nothing if the store is not paused.&lt;/li&gt;
&lt;li&gt;A manual &lt;code&gt;refresh()&lt;/code&gt; while paused updates the data and keeps the status &lt;code&gt;paused&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;dashboardStore&lt;/code&gt; singleton is exported and used by the provided &lt;code&gt;App.tsx&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💡 Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The state lives in a closure outside React, and every update must create a new snapshot object. &lt;code&gt;getSnapshot&lt;/code&gt; is compared with &lt;code&gt;Object.is&lt;/code&gt;, so returning a fresh object on every call causes an infinite render loop.&lt;/li&gt;
&lt;li&gt;The store is DOM-agnostic: it never reads &lt;code&gt;document.hidden&lt;/code&gt;. The provided &lt;code&gt;App.tsx&lt;/code&gt; calls &lt;code&gt;pause()&lt;/code&gt; and &lt;code&gt;resume()&lt;/code&gt; when tab visibility changes.&lt;/li&gt;
&lt;li&gt;Pausing is not only about clearing the interval. Invalidate the request already in flight, or its response can flip the status back to &lt;code&gt;live&lt;/code&gt; after the tab is hidden.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧪 Tests
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;exports the dashboardStore singleton&lt;/li&gt;
&lt;li&gt;renders the provided dashboard with the store&lt;/li&gt;
&lt;li&gt;starts with an idle snapshot and a stable reference&lt;/li&gt;
&lt;li&gt;notifies subscribers when the state changes&lt;/li&gt;
&lt;li&gt;stops notifying after unsubscribing&lt;/li&gt;
&lt;li&gt;fetches immediately when started&lt;/li&gt;
&lt;li&gt;shows a loading status while a request is in flight&lt;/li&gt;
&lt;li&gt;polls every five seconds&lt;/li&gt;
&lt;li&gt;starts only one interval and one fetch when start is called twice&lt;/li&gt;
&lt;li&gt;stops polling after stop is called&lt;/li&gt;
&lt;li&gt;keeps the last metrics when a request fails&lt;/li&gt;
&lt;li&gt;recovers on the next poll after an error&lt;/li&gt;
&lt;li&gt;discards a stale response that arrives after a newer one&lt;/li&gt;
&lt;li&gt;pauses polling and marks the dashboard as paused&lt;/li&gt;
&lt;li&gt;ignores an in-flight response that arrives after pausing&lt;/li&gt;
&lt;li&gt;resumes with an immediate fetch and restarts polling&lt;/li&gt;
&lt;li&gt;does nothing when resumed while already running&lt;/li&gt;
&lt;li&gt;stays paused when refreshed manually while paused&lt;/li&gt;
&lt;li&gt;keeps the snapshot reference stable between updates&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;By the end you'll know exactly what &lt;code&gt;useSyncExternalStore&lt;/code&gt; expects from a store: stable snapshots, safe subscriptions, idempotent polling, and cleanup that survives StrictMode, tab switches, and out-of-order responses.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.reactchallenges.com/challenges/build-external-store" rel="noopener noreferrer"&gt;🔥 Start the Challenge Now&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>frontendchallenge</category>
    </item>
    <item>
      <title>🚀 New React Challenge: Live dashboard</title>
      <dc:creator>ReactChallenges</dc:creator>
      <pubDate>Wed, 21 Oct 2026 10:41:23 +0000</pubDate>
      <link>https://dev.to/reactchallenges/new-react-challenge-live-dashboard-73n</link>
      <guid>https://dev.to/reactchallenges/new-react-challenge-live-dashboard-73n</guid>
      <description>&lt;p&gt;Most live dashboards start with &lt;code&gt;useState&lt;/code&gt; and a &lt;code&gt;setInterval&lt;/code&gt;, then end up with duplicate timers, stale closures, and requests firing from tabs nobody is looking at. This challenge flips the approach: the data lives in an external store, and your component only subscribes to it and owns the polling lifecycle.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧩 Overview
&lt;/h2&gt;

&lt;p&gt;You get a live metrics store and a dashboard to wire up. Use &lt;code&gt;useSyncExternalStore&lt;/code&gt; to read from the store, then coordinate the first load, polling, manual refresh, tab visibility, and failure states without duplicating a single value in React state.&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://www.reactchallenges.com/challenges/live-dashboard" rel="noopener noreferrer"&gt;https://www.reactchallenges.com/challenges/live-dashboard&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  ✅ Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Read from the provided store with &lt;code&gt;useSyncExternalStore&lt;/code&gt; (&lt;code&gt;dashboardStore.subscribe&lt;/code&gt; and &lt;code&gt;dashboardStore.getSnapshot&lt;/code&gt;); &lt;code&gt;store.ts&lt;/code&gt; is hidden and must be used as-is.&lt;/li&gt;
&lt;li&gt;On the first request, show the &lt;code&gt;Updating…&lt;/code&gt; status and the skeleton, with no metric cards rendered.&lt;/li&gt;
&lt;li&gt;After the first success, show &lt;code&gt;Live&lt;/code&gt; and render four cards: active users, revenue, requests, and error rate.&lt;/li&gt;
&lt;li&gt;Display the last successful update as &lt;code&gt;Updated at HH:MM:SS&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Start polling on mount when the document is visible, so the cards update without user interaction.&lt;/li&gt;
&lt;li&gt;During later polls (automatic or manual), keep the current cards on screen and show &lt;code&gt;Updating…&lt;/code&gt; until the request succeeds.&lt;/li&gt;
&lt;li&gt;Stop polling when the dashboard unmounts.&lt;/li&gt;
&lt;li&gt;Make the refresh button fetch immediately instead of waiting for the next interval, and disable it while updating.&lt;/li&gt;
&lt;li&gt;On failure, show &lt;code&gt;Error&lt;/code&gt; with the failure message and keep the last successful values on screen.&lt;/li&gt;
&lt;li&gt;Retry on the next interval after a failure.&lt;/li&gt;
&lt;li&gt;When the document becomes hidden, show &lt;code&gt;Paused&lt;/code&gt; and stop making requests.&lt;/li&gt;
&lt;li&gt;When the document becomes visible again, refresh immediately and resume polling.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💡 Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Pass &lt;code&gt;getSnapshot&lt;/code&gt; directly to &lt;code&gt;useSyncExternalStore&lt;/code&gt;. Don't copy the data into &lt;code&gt;useState&lt;/code&gt; or build a new object inside the snapshot, or React will treat every read as a change.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;start&lt;/code&gt; returns the cleanup function that stops polling. Return it from the effect so StrictMode's double mount doesn't leave two timers running.&lt;/li&gt;
&lt;li&gt;Pausing is not only about clearing the interval — decide what should happen to a request that is already in flight.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧪 Tests
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Shows the skeleton and the updating status on mount&lt;/li&gt;
&lt;li&gt;Renders the four metrics after the first fetch&lt;/li&gt;
&lt;li&gt;Shows the time of the last successful update&lt;/li&gt;
&lt;li&gt;Polls every five seconds and updates the metrics&lt;/li&gt;
&lt;li&gt;Refreshes immediately when the refresh button is clicked&lt;/li&gt;
&lt;li&gt;Shows an error and keeps the last successful data&lt;/li&gt;
&lt;li&gt;Retries on the next interval after an error&lt;/li&gt;
&lt;li&gt;Pauses polling while the tab is hidden&lt;/li&gt;
&lt;li&gt;Refreshes and resumes polling when the tab becomes visible&lt;/li&gt;
&lt;li&gt;Stops polling when the dashboard unmounts&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;You'll finish with a dashboard that stays consistent while data changes underneath it: a single source of truth, a polling lifecycle with real cleanup, and stale-while-revalidate UX that keeps the last good values on screen instead of flashing a skeleton.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.reactchallenges.com/challenges/live-dashboard" rel="noopener noreferrer"&gt;🔥 Start the Challenge Now&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>frontendchallenge</category>
    </item>
    <item>
      <title>🚀 New React Challenge: Undo / Redo</title>
      <dc:creator>ReactChallenges</dc:creator>
      <pubDate>Wed, 07 Oct 2026 09:04:45 +0000</pubDate>
      <link>https://dev.to/reactchallenges/new-react-challenge-undo-redo-40h0</link>
      <guid>https://dev.to/reactchallenges/new-react-challenge-undo-redo-40h0</guid>
      <description>&lt;p&gt;Most apps let users make changes but never let them take them back. This challenge is about building the mechanism that changes everything: a history you can rewind.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧩 Overview
&lt;/h2&gt;

&lt;p&gt;Build a notes editor whose add, edit, toggle, and delete actions are tracked in a &lt;code&gt;useReducer&lt;/code&gt; past/present/future history, so every change can be undone and redone with buttons or keyboard shortcuts.&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://www.reactchallenges.com/challenges/undo-redo" rel="noopener noreferrer"&gt;https://www.reactchallenges.com/challenges/undo-redo&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  ✅ Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The list starts with the notes "Buy groceries" and "Walk the dog".&lt;/li&gt;
&lt;li&gt;Each note is editable through an input.&lt;/li&gt;
&lt;li&gt;Each note has a done toggle and a delete button.&lt;/li&gt;
&lt;li&gt;Undo and redo are disabled on first render.&lt;/li&gt;
&lt;li&gt;Adding a note appends it to the list and clears the new-note field.&lt;/li&gt;
&lt;li&gt;A change enables undo; undoing restores the previous list, disables undo when there is nothing left to undo, and enables redo.&lt;/li&gt;
&lt;li&gt;Redo reapplies an undone change and disables itself once there is nothing left to redo.&lt;/li&gt;
&lt;li&gt;Adding, editing, toggling, and deleting a note can each be undone.&lt;/li&gt;
&lt;li&gt;An undone change can be redone.&lt;/li&gt;
&lt;li&gt;Consecutive edits to the same note collapse into a single undo step.&lt;/li&gt;
&lt;li&gt;An edit that does not change the text is ignored and adds no history.&lt;/li&gt;
&lt;li&gt;Adding an empty or whitespace-only note is ignored and adds no history.&lt;/li&gt;
&lt;li&gt;Undo is triggered by Cmd/Ctrl+Z.&lt;/li&gt;
&lt;li&gt;Redo is triggered by Shift+Ctrl+Z.&lt;/li&gt;
&lt;li&gt;Pressing undo with no history or redo with nothing to redo leaves the list unchanged.&lt;/li&gt;
&lt;li&gt;The status line reports how many undo and redo steps are available.&lt;/li&gt;
&lt;li&gt;New notes always get unique identifiers, even after undoing and adding again.&lt;/li&gt;
&lt;li&gt;Making a new change after undoing clears the redo stack.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💡 Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The history shape most people reach for is &lt;code&gt;{ past, present, future }&lt;/code&gt;: &lt;code&gt;present&lt;/code&gt; is what renders, while &lt;code&gt;past&lt;/code&gt; and &lt;code&gt;future&lt;/code&gt; are stacks of snapshots.&lt;/li&gt;
&lt;li&gt;Return the same state object for a no-op (a blank note, an edit that doesn't change the text, undo/redo with an empty stack) so React bails out and history stays clean.&lt;/li&gt;
&lt;li&gt;Keep the id counter outside the history — rewinding it on undo would let two different notes share an id.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧪 Tests
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;renders the initial notes&lt;/li&gt;
&lt;li&gt;disables undo and redo on load&lt;/li&gt;
&lt;li&gt;adds a note and clears the input&lt;/li&gt;
&lt;li&gt;enables undo after a change and disables it again after undoing&lt;/li&gt;
&lt;li&gt;redoes an undone change&lt;/li&gt;
&lt;li&gt;undoes a deletion and restores the note&lt;/li&gt;
&lt;li&gt;undoes a toggle and restores the previous state&lt;/li&gt;
&lt;li&gt;undoes an edit and restores the previous text&lt;/li&gt;
&lt;li&gt;collapses continuous edits to one note into a single undo step&lt;/li&gt;
&lt;li&gt;ignores an edit that does not change the text&lt;/li&gt;
&lt;li&gt;does not push history when adding an empty note&lt;/li&gt;
&lt;li&gt;does not push history when adding a whitespace-only note&lt;/li&gt;
&lt;li&gt;undoes with Ctrl+Z&lt;/li&gt;
&lt;li&gt;undoes with Cmd+Z&lt;/li&gt;
&lt;li&gt;redoes with Shift+Ctrl+Z&lt;/li&gt;
&lt;li&gt;does nothing when undo is pressed with no history&lt;/li&gt;
&lt;li&gt;does nothing when redo is pressed with no future&lt;/li&gt;
&lt;li&gt;reports the available undo and redo steps&lt;/li&gt;
&lt;li&gt;keeps note identifiers unique after undo and redo&lt;/li&gt;
&lt;li&gt;clears the redo stack when a new change is made&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;Work through it and you'll come away knowing how to model reversible state with a reducer — a skill that shows up everywhere from text editors to form builders to drag-and-drop canvases.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.reactchallenges.com/challenges/undo-redo" rel="noopener noreferrer"&gt;🔥 Start the Challenge Now&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>frontendchallenge</category>
    </item>
    <item>
      <title>🚀 𝗡𝗲𝘄 𝗥𝗲𝗮𝗰𝘁 𝗖𝗵𝗮𝗹𝗹𝗲𝗻𝗴𝗲: Virtualized List</title>
      <dc:creator>ReactChallenges</dc:creator>
      <pubDate>Wed, 30 Sep 2026 11:46:25 +0000</pubDate>
      <link>https://dev.to/reactchallenges/-virtualized-list-4593</link>
      <guid>https://dev.to/reactchallenges/-virtualized-list-4593</guid>
      <description>&lt;p&gt;Ever hit a wall when a list grows to thousands of rows and React starts to choke? Mounting 10,000 DOM nodes at once is the problem — rendering only what fits on screen is the fix.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧩 Overview
&lt;/h2&gt;

&lt;p&gt;Build a virtualized list of 10,000 contacts that mounts only the rows visible in the scroll viewport (plus a small overscan), using fixed row heights and windowing math.&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://www.reactchallenges.com/challenges/virtualized-list" rel="noopener noreferrer"&gt;https://www.reactchallenges.com/challenges/virtualized-list&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  ✅ Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Render a virtualized directory of 10,000 contacts.&lt;/li&gt;
&lt;li&gt;Mount only a small window of rows — far fewer than the 10,000 in the dataset.&lt;/li&gt;
&lt;li&gt;Scroll through the entire dataset, not just the mounted rows.&lt;/li&gt;
&lt;li&gt;Size the scrollable area to the full dataset so the scrollbar spans the whole list.&lt;/li&gt;
&lt;li&gt;Unmount rows that leave the viewport and mount the ones that enter it.&lt;/li&gt;
&lt;li&gt;Keep a few overscan rows above and below the visible window.&lt;/li&gt;
&lt;li&gt;Show the first and last mounted rows in a stats line: &lt;code&gt;Showing X–Y of 10000&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Display each contact's name and email in its row.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💡 Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Put all the windowing logic in &lt;code&gt;App.tsx&lt;/code&gt;: track &lt;code&gt;scrollTop&lt;/code&gt;, measure the viewport's &lt;code&gt;clientHeight&lt;/code&gt;, and compute the range of rows to mount.&lt;/li&gt;
&lt;li&gt;Measure the viewport height in a layout effect — it's the moment the layout is ready.&lt;/li&gt;
&lt;li&gt;Clamp the range so overscan never renders rows before the first or after the last contact.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧪 Tests
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Renders the app title&lt;/li&gt;
&lt;li&gt;Only mounts a small window of rows, not the whole dataset&lt;/li&gt;
&lt;li&gt;Renders the first contacts on load&lt;/li&gt;
&lt;li&gt;Sizes the scrollable area to the full dataset&lt;/li&gt;
&lt;li&gt;Shows the first and last rendered rows in the stats&lt;/li&gt;
&lt;li&gt;Renders more rows than fit on screen (overscan)&lt;/li&gt;
&lt;li&gt;Shows the name and email for each mounted row&lt;/li&gt;
&lt;li&gt;Moves the window down when scrolling&lt;/li&gt;
&lt;li&gt;Restores the first rows when scrolling back to the top&lt;/li&gt;
&lt;li&gt;Renders the last contact when scrolled to the bottom&lt;/li&gt;
&lt;li&gt;Mounts overscan rows above the visible window when scrolled&lt;/li&gt;
&lt;li&gt;Never renders rows above the first one&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;This challenge is a hands-on way to understand virtualization from scratch — the exact pattern behind every serious long-list library. Practice windowing math, &lt;code&gt;useLayoutEffect&lt;/code&gt;, and derived rendering, and your lists will stop freezing for good.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.reactchallenges.com/challenges/virtualized-list" rel="noopener noreferrer"&gt;🔥 Start the Challenge Now&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>frontendchallenge</category>
    </item>
    <item>
      <title>🚀 New React Challenge: OTP Input</title>
      <dc:creator>ReactChallenges</dc:creator>
      <pubDate>Wed, 23 Sep 2026 12:00:08 +0000</pubDate>
      <link>https://dev.to/reactchallenges/new-react-challenge-otp-input-1ld9</link>
      <guid>https://dev.to/reactchallenges/new-react-challenge-otp-input-1ld9</guid>
      <description>&lt;p&gt;One-time-password inputs look simple until you try to build one. Auto-advancing focus, paste handling, and keyboard navigation all have to work together — and that's exactly what this challenge asks you to wire up.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧩 Overview
&lt;/h2&gt;

&lt;p&gt;Build a six-field OTP input that moves focus as you type, accepts a pasted code, and validates it against a demo code.&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://www.reactchallenges.com/challenges/otp-input" rel="noopener noreferrer"&gt;https://www.reactchallenges.com/challenges/otp-input&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  ✅ Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Six single-character inputs are rendered, one per digit.&lt;/li&gt;
&lt;li&gt;The first input is focused on mount.&lt;/li&gt;
&lt;li&gt;Typing a digit fills the focused input and moves focus to the next input.&lt;/li&gt;
&lt;li&gt;Non-numeric characters are ignored.&lt;/li&gt;
&lt;li&gt;Backspace clears the current digit and stays in place.&lt;/li&gt;
&lt;li&gt;Backspace on an already-empty input clears the previous digit and moves focus to it.&lt;/li&gt;
&lt;li&gt;ArrowLeft and ArrowRight move focus between inputs.&lt;/li&gt;
&lt;li&gt;Pasting a code fills the inputs with the pasted digits; digits beyond six are ignored.&lt;/li&gt;
&lt;li&gt;The status text reads "Waiting for code…" while the code is incomplete.&lt;/li&gt;
&lt;li&gt;When all six digits are filled and match the demo code, the status reads "Code verified".&lt;/li&gt;
&lt;li&gt;When all six digits are filled but do not match, the status reads "Invalid code. Try again."&lt;/li&gt;
&lt;li&gt;The reset button clears all inputs, refocuses the first input, and resets the status.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💡 Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The six inputs are controlled: whatever logic you run in the change handler decides what actually sticks in state, so invalid characters never persist.&lt;/li&gt;
&lt;li&gt;You need to move focus between inputs imperatively — plan how to keep a reference to each field.&lt;/li&gt;
&lt;li&gt;A single interaction can deliver more than one digit at once (pasting a full code), not just one keypress.&lt;/li&gt;
&lt;li&gt;Call &lt;code&gt;preventDefault()&lt;/code&gt; on the keyboard and paste handlers so the browser doesn't also move the caret or insert text on its own.&lt;/li&gt;
&lt;li&gt;Prefer deriving the status from the current values instead of storing it as separate state that can drift out of sync.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧪 Tests
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;renders six inputs&lt;/li&gt;
&lt;li&gt;focuses the first input on mount&lt;/li&gt;
&lt;li&gt;renders the demo code&lt;/li&gt;
&lt;li&gt;types a digit and moves focus to the next input&lt;/li&gt;
&lt;li&gt;ignores non-numeric characters&lt;/li&gt;
&lt;li&gt;backspace clears the current digit and stays in place&lt;/li&gt;
&lt;li&gt;backspace on an empty input clears the previous digit&lt;/li&gt;
&lt;li&gt;arrow keys move focus between inputs&lt;/li&gt;
&lt;li&gt;pastes the demo code and verifies it&lt;/li&gt;
&lt;li&gt;shows an error for a wrong code&lt;/li&gt;
&lt;li&gt;truncates extra digits when pasting more than six&lt;/li&gt;
&lt;li&gt;reset clears the inputs and refocuses the first&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;Mastering imperative focus management and derived state in a tiny, familiar UI. That's the skill this challenge leaves you with — useful every time you build auth, 2FA, or payment flows.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.reactchallenges.com/challenges/otp-input" rel="noopener noreferrer"&gt;🔥 Start the Challenge Now&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>typescript</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Context API vs Redux</title>
      <dc:creator>ReactChallenges</dc:creator>
      <pubDate>Sun, 20 Sep 2026 11:36:50 +0000</pubDate>
      <link>https://dev.to/reactchallenges/context-api-vs-redux-3o5e</link>
      <guid>https://dev.to/reactchallenges/context-api-vs-redux-3o5e</guid>
      <description>&lt;p&gt;The question is usually framed as "which one is better", but that's the wrong question. Context and Redux do different jobs. The important part is understanding how each one updates its consumers.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;👉 Try it in practice: &lt;a href="https://www.reactchallenges.com/challenges/shopping-cart" rel="noopener noreferrer"&gt;Shopping Cart with Context&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What Context actually does
&lt;/h2&gt;

&lt;p&gt;Context lets a component read and subscribe to a value without threading it down through props. The context object itself does not hold data; it only describes what can be provided and read. To make the value change, you pair the provider with &lt;code&gt;useState&lt;/code&gt; or &lt;code&gt;useReducer&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ThemeContext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;light&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;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;theme&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setTheme&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;light&lt;/span&gt;&lt;span class="dl"&gt;"&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;&lt;/span&gt;&lt;span class="nc"&gt;ThemeContext&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="si"&gt;}&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;Page&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;ThemeContext&lt;/span&gt;&lt;span class="p"&gt;&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;The key detail, from the React docs: when the value you pass to a provider changes, React re-renders every component that reads that context. It compares the old and new values with &lt;code&gt;Object.is&lt;/code&gt;. There are no selectors, so you can't subscribe to just one field of the value.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Redux adds
&lt;/h2&gt;

&lt;p&gt;Redux is a centralized store with a single flow: action, reducer, store. Around that flow you get middleware, Redux DevTools, and an action history, so you can answer "when did this slice change and where did the data come from?".&lt;/p&gt;

&lt;p&gt;Its real advantage over Context is &lt;code&gt;useSelector&lt;/code&gt;. A component subscribes to the result it selects, not to the whole store:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useSelector&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;s&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;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&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;theme&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useSelector&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;s&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;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change &lt;code&gt;cart&lt;/code&gt; and the component reading &lt;code&gt;theme&lt;/code&gt; does not re-render. With Context, it would.&lt;/p&gt;

&lt;h2&gt;
  
  
  The re-render difference
&lt;/h2&gt;

&lt;p&gt;A Context subscription is to the context value as a whole, not to individual fields. Put &lt;code&gt;{ user, cart, theme }&lt;/code&gt; in a single context and changing &lt;code&gt;cart&lt;/code&gt; re-renders the component that only reads &lt;code&gt;theme&lt;/code&gt; too. You can fix this by splitting into multiple contexts and memoizing values, but that's work you do by hand. Redux gives you granular subscriptions through selectors.&lt;/p&gt;

&lt;h2&gt;
  
  
  When to use each
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Context&lt;/strong&gt; for simple shared values with few consumers: theme, locale, current user, and state scoped to one feature. Zero dependencies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Redux&lt;/strong&gt; when shared client state gets large, is used in many places, or has update logic that's getting complex. It also helps when you need to inspect how state changes over time with Redux DevTools.&lt;/p&gt;

&lt;p&gt;Data fetched from an API is server state and belongs in SWR or React Query, not in either of these.&lt;/p&gt;

&lt;h2&gt;
  
  
  A real example: the shopping cart
&lt;/h2&gt;

&lt;p&gt;A cart with a few items, a header badge, and a checkout button is fine in Context.&lt;/p&gt;

&lt;p&gt;Watch what happens as it grows: a coupon field, a quantity stepper, a "save for later" list. Now items, coupon, and saved share one context. Updating items re-renders the coupon and saved consumers too. Put the coupon draft in that same context and every keystroke re-renders the header badge.&lt;/p&gt;

&lt;p&gt;That's where selectors earn their keep: components can subscribe to different slices of state independently, and a component re-renders only when the piece it reads changes. Redux DevTools and action history are the bonus on top.&lt;/p&gt;

&lt;p&gt;Start with Context. Reach for a store when the state and its consumers get complex enough to justify it, not before.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;👉 Build both and compare: &lt;a href="https://www.reactchallenges.com/challenges/shopping-cart-with-redux" rel="noopener noreferrer"&gt;Shopping Cart with Redux&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>redux</category>
    </item>
    <item>
      <title>🚀 New React Challenge: Command Palette</title>
      <dc:creator>ReactChallenges</dc:creator>
      <pubDate>Wed, 16 Sep 2026 10:08:15 +0000</pubDate>
      <link>https://dev.to/reactchallenges/new-react-challenge-command-palette-24jn</link>
      <guid>https://dev.to/reactchallenges/new-react-challenge-command-palette-24jn</guid>
      <description>&lt;p&gt;Search bars are fine until someone hits Cmd/Ctrl+K. A command palette replaces hunting through menus with a keyboard-first layer that filters as you type — and building one forces you to combine global keyboard handling, focus management and correct ARIA semantics in a single component.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧩 Overview
&lt;/h2&gt;

&lt;p&gt;Build a keyboard-driven command palette (Cmd/Ctrl+K) with fuzzy filtering, arrow-key navigation, a focus trap and proper combobox/listbox semantics.&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://www.reactchallenges.com/challenges/command-palette" rel="noopener noreferrer"&gt;https://www.reactchallenges.com/challenges/command-palette&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  ✅ Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The palette is hidden on first render.&lt;/li&gt;
&lt;li&gt;Clicking the trigger opens the palette.&lt;/li&gt;
&lt;li&gt;Pressing Cmd/Ctrl+K opens the palette, and pressing it again closes it.&lt;/li&gt;
&lt;li&gt;Pressing Escape closes the palette.&lt;/li&gt;
&lt;li&gt;Clicking the backdrop closes the palette, while clicking inside the panel keeps it open.&lt;/li&gt;
&lt;li&gt;When the palette opens, the search input receives focus and is empty.&lt;/li&gt;
&lt;li&gt;The palette lists every command.&lt;/li&gt;
&lt;li&gt;Typing filters the commands by fuzzy match: every character of the query must appear in the label in order, ignoring case.&lt;/li&gt;
&lt;li&gt;When nothing matches, show &lt;code&gt;No results for "&amp;lt;query&amp;gt;"&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Clearing the query restores the full list.&lt;/li&gt;
&lt;li&gt;The first command is highlighted when the palette opens and whenever the query changes.&lt;/li&gt;
&lt;li&gt;ArrowDown moves the highlight to the next command, wrapping from the last one to the first.&lt;/li&gt;
&lt;li&gt;ArrowUp moves the highlight to the previous command, wrapping from the first one to the last.&lt;/li&gt;
&lt;li&gt;Enter executes the highlighted command and closes the palette.&lt;/li&gt;
&lt;li&gt;Clicking a command executes it and closes the palette.&lt;/li&gt;
&lt;li&gt;Executing a command sets the &lt;code&gt;Last action&lt;/code&gt; text to that command's label.&lt;/li&gt;
&lt;li&gt;While the palette is open, focus stays inside it when pressing Tab.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💡 Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Open and close from a single &lt;code&gt;window&lt;/code&gt; &lt;code&gt;keydown&lt;/code&gt; listener for Cmd/Ctrl+K and Escape, and call &lt;code&gt;preventDefault()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Filter by subsequence, not &lt;code&gt;includes&lt;/code&gt; ("gch" matches "Go to Challenges"), and reset &lt;code&gt;activeIndex&lt;/code&gt; when the query changes.&lt;/li&gt;
&lt;li&gt;Focus the input on open and keep focus trapped inside the panel by listening for &lt;code&gt;focusin&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧪 Tests
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;keeps the palette hidden on first render&lt;/li&gt;
&lt;li&gt;opens the palette when the trigger is clicked&lt;/li&gt;
&lt;li&gt;opens the palette with Cmd/Ctrl+K&lt;/li&gt;
&lt;li&gt;focuses the search input when opened&lt;/li&gt;
&lt;li&gt;closes the palette when the shortcut is pressed again&lt;/li&gt;
&lt;li&gt;closes the palette on Escape&lt;/li&gt;
&lt;li&gt;closes the palette when the backdrop is clicked&lt;/li&gt;
&lt;li&gt;keeps the palette open when clicking inside the panel&lt;/li&gt;
&lt;li&gt;renders every command&lt;/li&gt;
&lt;li&gt;filters commands as the user types&lt;/li&gt;
&lt;li&gt;matches non-contiguous characters&lt;/li&gt;
&lt;li&gt;is case-insensitive&lt;/li&gt;
&lt;li&gt;shows a no-results message when nothing matches&lt;/li&gt;
&lt;li&gt;restores the full list when the query is cleared&lt;/li&gt;
&lt;li&gt;clears the query when the palette is reopened&lt;/li&gt;
&lt;li&gt;highlights the first command by default&lt;/li&gt;
&lt;li&gt;moves the highlight down with ArrowDown&lt;/li&gt;
&lt;li&gt;wraps from the first to the last with ArrowUp&lt;/li&gt;
&lt;li&gt;wraps from the last to the first with ArrowDown&lt;/li&gt;
&lt;li&gt;resets the highlight when the query changes&lt;/li&gt;
&lt;li&gt;executes the highlighted command with Enter&lt;/li&gt;
&lt;li&gt;executes a command when clicked&lt;/li&gt;
&lt;li&gt;traps focus inside the palette on Tab&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;If you want to practice keyboard-driven UI the way real apps do it, this challenge gives you the full loop: open, filter, navigate, execute and trap focus — with 23 tests to keep you honest.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.reactchallenges.com/challenges/command-palette" rel="noopener noreferrer"&gt;🔥 Start the Challenge Now&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>frontendchallenge</category>
    </item>
    <item>
      <title>5 common TypeScript interview questions</title>
      <dc:creator>ReactChallenges</dc:creator>
      <pubDate>Thu, 10 Sep 2026 09:40:33 +0000</pubDate>
      <link>https://dev.to/reactchallenges/5-common-typescript-interview-questions-10jb</link>
      <guid>https://dev.to/reactchallenges/5-common-typescript-interview-questions-10jb</guid>
      <description>&lt;p&gt;These five questions show up in almost every TypeScript interview. They're not tricky syntax puzzles. They test whether you understand the type system well enough to use it on purpose instead of just making the compiler happy.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;any&lt;/code&gt; vs &lt;code&gt;unknown&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;any&lt;/code&gt; turns type checking off. Once a value is &lt;code&gt;any&lt;/code&gt;, TypeScript stops protecting you and mistakes slip through until runtime. &lt;code&gt;unknown&lt;/code&gt; is the safe counterpart: it can hold anything, but you must narrow it before using it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toUpperCase&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// ✅ no error&lt;/span&gt;
&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;thisDoesNotExist&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// ✅ no error either 💀&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;u&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toUpperCase&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// ❌ 'u' is of type 'unknown'&lt;/span&gt;

&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;u&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;string&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="nx"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toUpperCase&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// ✅ narrowed to string&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reach for &lt;code&gt;unknown&lt;/code&gt; when the type is genuinely unknown, like API responses, &lt;code&gt;JSON.parse&lt;/code&gt;, or &lt;code&gt;catch&lt;/code&gt; variables, and never reach for &lt;code&gt;any&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;interface&lt;/code&gt; vs &lt;code&gt;type&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Both describe object shapes and are mostly interchangeable. The real differences are what each one can express.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;interface&lt;/code&gt; supports &lt;strong&gt;declaration merging&lt;/strong&gt;; &lt;code&gt;type&lt;/code&gt; doesn't.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;type&lt;/code&gt; can express unions, intersections, tuples, and primitives; &lt;code&gt;interface&lt;/code&gt; only describes object-like shapes.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;interface&lt;/code&gt; extends with &lt;code&gt;extends&lt;/code&gt;; &lt;code&gt;type&lt;/code&gt; composes with &lt;code&gt;&amp;amp;&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="c1"&gt;// merged: { name: string; age: number }&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// only possible with type&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Declaration merging cuts both ways: it lets libraries augment existing types (like extending &lt;code&gt;Window&lt;/code&gt;), but it can also merge a typo into a valid type. A common convention is &lt;code&gt;interface&lt;/code&gt; for object APIs and &lt;code&gt;type&lt;/code&gt; for unions and computed types.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generics
&lt;/h2&gt;

&lt;p&gt;Generics let you write code that works with many types while preserving the relationship between input and output. Without them you'd duplicate the function per type or fall back to &lt;code&gt;any&lt;/code&gt; and lose the return type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;first&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&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;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="p"&gt;[]):&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;undefined&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;items&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="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;first&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt; &lt;span class="c1"&gt;// number | undefined&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;first&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a&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="s2"&gt;b&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt; &lt;span class="c1"&gt;// string | undefined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can constrain them when you need to rely on some structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getProperty&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;K&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="kr"&gt;keyof&lt;/span&gt; &lt;span class="nx"&gt;T&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;obj&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;K&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;K&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="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&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;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nf"&gt;getProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ✅ string&lt;/span&gt;
&lt;span class="nf"&gt;getProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;age&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ❌ "age" is not assignable to keyof typeof user&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The definition is easy to recite. The interview signal is being able to show a case where a generic removed duplication or a lost type.&lt;/p&gt;

&lt;h2&gt;
  
  
  Utility types
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Partial&lt;/code&gt;, &lt;code&gt;Pick&lt;/code&gt;, &lt;code&gt;Omit&lt;/code&gt;, and &lt;code&gt;Record&lt;/code&gt; are built-in generics. They're not magic, but &lt;strong&gt;mapped types&lt;/strong&gt; that transform an existing type into a new one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;PartialUser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Partial&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// every property optional&lt;/span&gt;
&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;UserPreview&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Pick&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&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="c1"&gt;// only id and name&lt;/span&gt;
&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;UserWithoutEmail&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Omit&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email&lt;/span&gt;&lt;span class="dl"&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="c1"&gt;// everything except email&lt;/span&gt;
&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;UsersById&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Record&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// { [key: string]: User }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Under the hood, &lt;code&gt;Partial&lt;/code&gt; is roughly this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nb"&gt;Partial&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&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="nx"&gt;K&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="kr"&gt;keyof&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="p"&gt;]?:&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;K&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;Knowing the mapping is what separates "I know they exist" from "I know how to build my own".&lt;/p&gt;

&lt;h2&gt;
  
  
  Type guards
&lt;/h2&gt;

&lt;p&gt;A type guard is an expression that gives TypeScript information it can use to &lt;strong&gt;narrow&lt;/strong&gt; a broader type into a more specific one within a block. Common narrowing checks include &lt;code&gt;typeof&lt;/code&gt;, &lt;code&gt;instanceof&lt;/code&gt;, &lt;code&gt;in&lt;/code&gt;, and equality checks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;format&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="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&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="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;string&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="k"&gt;return&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;toUpperCase&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// string&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;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toFixed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// number&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you want to reuse a check across your code, wrap it in a named type guard using a &lt;strong&gt;type predicate&lt;/strong&gt; (&lt;code&gt;x is T&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Cat&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;meow&lt;/span&gt;&lt;span class="p"&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="k"&gt;void&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Dog&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;bark&lt;/span&gt;&lt;span class="p"&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="k"&gt;void&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;isCat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;animal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Cat&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;Dog&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;animal&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;Cat&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;meow&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;animal&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;Now TypeScript can narrow the type when you call the guard:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;speak&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;animal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Cat&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;Dog&lt;/span&gt;&lt;span class="p"&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="nf"&gt;isCat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;animal&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;animal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;meow&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Cat&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;animal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bark&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Dog&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;code&gt;animal is Cat&lt;/code&gt; return type is a contract: TypeScript trusts it and narrows &lt;code&gt;animal&lt;/code&gt; to &lt;code&gt;Cat&lt;/code&gt; when the function returns &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That means the logic inside the guard is your responsibility. If the predicate is wrong, TypeScript won't catch the resulting bug.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>react</category>
      <category>programming</category>
    </item>
    <item>
      <title>🚀 New React Challenge: Infinite Scroll</title>
      <dc:creator>ReactChallenges</dc:creator>
      <pubDate>Wed, 09 Sep 2026 09:53:24 +0000</pubDate>
      <link>https://dev.to/reactchallenges/new-react-challenge-infinite-scroll-1mi2</link>
      <guid>https://dev.to/reactchallenges/new-react-challenge-infinite-scroll-1mi2</guid>
      <description>&lt;p&gt;"Load more" buttons are the easy way out. Real feeds — Twitter, Instagram, your chat app — load the next page the moment you scroll near the bottom. That magic is the &lt;strong&gt;Intersection Observer API&lt;/strong&gt;, and it's much cleaner than the old scroll-listener + throttle dance.&lt;/p&gt;

&lt;p&gt;This challenge gets you building an infinite scroll list of &lt;strong&gt;Rick &amp;amp; Morty characters&lt;/strong&gt; with React 19's Suspense-driven &lt;code&gt;use()&lt;/code&gt; fetching already in place. Your job: make the next page fetch itself.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧩 Overview
&lt;/h2&gt;

&lt;p&gt;Build an infinite scroll list of Rick and Morty characters using the &lt;strong&gt;Intersection Observer API&lt;/strong&gt; — the next page is fetched automatically when a sentinel element enters the viewport, building on an existing &lt;code&gt;use()&lt;/code&gt; + Suspense data-fetching setup.&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://www.reactchallenges.com/challenges/infinite-scroll" rel="noopener noreferrer"&gt;https://www.reactchallenges.com/challenges/infinite-scroll&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  ✅ Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Keep the starter's &lt;code&gt;use()&lt;/code&gt; + Suspense first-page fetch as the starting point&lt;/li&gt;
&lt;li&gt;Follow the API pagination and read the next page URL from &lt;code&gt;data.info.next&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Load the next page automatically when the user scrolls to the bottom — no button&lt;/li&gt;
&lt;li&gt;Trigger the load from a sentinel element observed by the Intersection Observer&lt;/li&gt;
&lt;li&gt;Append new characters to the existing list instead of replacing them&lt;/li&gt;
&lt;li&gt;Show a loading indicator while the next page is being fetched&lt;/li&gt;
&lt;li&gt;Hide the loading indicator once the page finishes loading&lt;/li&gt;
&lt;li&gt;Show an end-of-list message when there are no more pages&lt;/li&gt;
&lt;li&gt;Stop fetching once the end is reached — no requests when &lt;code&gt;info.next&lt;/code&gt; is &lt;code&gt;null&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Disconnect the observer when the component unmounts&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💡 Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;App&lt;/code&gt; is fully wired: title, layout, and the Suspense fallback are done — all your work happens inside &lt;code&gt;Characters()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The components file is read-only, and the API follows the classic &lt;code&gt;{ info: { next, prev }, results: [...] }&lt;/code&gt; Rick &amp;amp; Morty response shape.&lt;/li&gt;
&lt;li&gt;Watch out: a couple of tests pass with the starter code simply because nothing fetches yet — they only start validating real behavior once your observer is in place.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧪 Tests
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;renders the app title&lt;/li&gt;
&lt;li&gt;shows skeleton while loading&lt;/li&gt;
&lt;li&gt;renders first-page characters after loading&lt;/li&gt;
&lt;li&gt;observes the sentinel element&lt;/li&gt;
&lt;li&gt;loads the next page when the sentinel enters the viewport&lt;/li&gt;
&lt;li&gt;appends characters instead of replacing them&lt;/li&gt;
&lt;li&gt;loads the third page on repeated intersections&lt;/li&gt;
&lt;li&gt;shows a loading indicator while fetching the next page&lt;/li&gt;
&lt;li&gt;hides the loading indicator once the next page loads&lt;/li&gt;
&lt;li&gt;shows end of list when there are no more pages&lt;/li&gt;
&lt;li&gt;does not fetch again once the end is reached&lt;/li&gt;
&lt;li&gt;disconnects the observer on unmount&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;Infinite scroll is one of those tasks that shows up again and again in frontend interviews and real products.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.reactchallenges.com/challenges/infinite-scroll" rel="noopener noreferrer"&gt;🔥 Start the Challenge Now&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>frontendchallenge</category>
    </item>
  </channel>
</rss>
