<?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: Davide Cannerozzi</title>
    <description>The latest articles on DEV Community by Davide Cannerozzi (@davidecannerozzi).</description>
    <link>https://dev.to/davidecannerozzi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F691777%2Fe8af4d4b-8cc8-436e-a204-fa8a6f56282e.jpeg</url>
      <title>DEV Community: Davide Cannerozzi</title>
      <link>https://dev.to/davidecannerozzi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/davidecannerozzi"/>
    <language>en</language>
    <item>
      <title>Understanding React's useTransition Hook: Keep Your UI Smooth</title>
      <dc:creator>Davide Cannerozzi</dc:creator>
      <pubDate>Wed, 03 Dec 2025 19:58:59 +0000</pubDate>
      <link>https://dev.to/davidecannerozzi/understanding-reacts-usetransition-hook-keep-your-ui-smooth-59ce</link>
      <guid>https://dev.to/davidecannerozzi/understanding-reacts-usetransition-hook-keep-your-ui-smooth-59ce</guid>
      <description>&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Imagine you're building a search feature for a list of 2,000 products. Every time a user types a letter, your app filters the entire list and re-renders it. What happens? The input lags. The user's typing feels sluggish and frustrating.&lt;/p&gt;

&lt;p&gt;This is a common problem when dealing with heavy updates in React. What if we could tell React: "Hey, updating this list is important, but keeping the input smooth is MORE important"?&lt;/p&gt;

&lt;p&gt;That's exactly what &lt;code&gt;useTransition&lt;/code&gt; does.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is useTransition?
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;useTransition&lt;/code&gt; is a React hook (introduced in React 18) that lets you mark certain updates as &lt;strong&gt;non-urgent&lt;/strong&gt;. This means React can prioritize user interactions (like typing) over heavy rendering tasks (like filtering a huge list).&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic Syntax
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&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;isPending&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;startTransition&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useTransition&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;startTransition&lt;/code&gt;&lt;/strong&gt;: A function that wraps non-urgent updates&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;isPending&lt;/code&gt;&lt;/strong&gt;: A boolean that tells you if the transition is still in progress (useful for showing loading states)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How It Works
&lt;/h2&gt;

&lt;p&gt;React categorizes updates into two types:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Urgent updates&lt;/strong&gt;: User interactions like typing, clicking, hovering&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Non-urgent updates&lt;/strong&gt;: Heavy operations like filtering, sorting, complex calculations&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When you wrap an update in &lt;code&gt;startTransition&lt;/code&gt;, you're telling React: "This can wait. Keep the UI responsive first."&lt;/p&gt;

&lt;h2&gt;
  
  
  Real Example: Filtering a Large List
&lt;/h2&gt;

&lt;p&gt;Let's build a practical example. We have 2,000 products and want to filter them as the user types.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Data
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// hugeList.ts&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Product&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;id&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="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="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;hugeList&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;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="nx"&gt;i&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="s2"&gt;`Product &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&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;h3&gt;
  
  
  Without useTransition (Laggy)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&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;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setValue&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="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;filteredProducts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setFilteredProducts&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;hugeList&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;handleChange&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newValue&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;setValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="c1"&gt;// This blocks the input!&lt;/span&gt;
    &lt;span class="nf"&gt;setFilteredProducts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nx"&gt;hugeList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;item&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;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newValue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&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="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;input&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;value&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;onChange&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&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;handleChange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&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="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;ProductList&lt;/span&gt; &lt;span class="na"&gt;items&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;filteredProducts&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;/&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;&lt;strong&gt;Problem&lt;/strong&gt;: Every keystroke triggers a heavy filter operation that blocks the input.&lt;/p&gt;

&lt;h3&gt;
  
  
  With useTransition (Smooth)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&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;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setValue&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="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;filteredProducts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setFilteredProducts&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;hugeList&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;isPending&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;startTransition&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useTransition&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;startTransition&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;setFilteredProducts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nx"&gt;hugeList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;item&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;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;includes&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;toLowerCase&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="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;input&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;value&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;onChange&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&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;setValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&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="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;isPending&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Filtering...&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ProductList&lt;/span&gt; &lt;span class="na"&gt;items&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;filteredProducts&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;/&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;&lt;strong&gt;Result&lt;/strong&gt;: The input stays smooth! React keeps it responsive while filtering happens in the background.&lt;/p&gt;

&lt;h2&gt;
  
  
  When to Use useTransition
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Perfect for:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Filtering or sorting large lists (1,000+ items)&lt;/li&gt;
&lt;li&gt;Heavy calculations that slow down the UI&lt;/li&gt;
&lt;li&gt;Complex rendering (charts, graphs, data tables)&lt;/li&gt;
&lt;li&gt;Tab navigation with heavy content&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When NOT to Use useTransition
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Skip it for:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Small, fast updates (simple toggles, counters)&lt;/li&gt;
&lt;li&gt;Updates that must happen immediately&lt;/li&gt;
&lt;li&gt;API calls (better handled with loading states and async patterns)&lt;/li&gt;
&lt;li&gt;Animations (use CSS or animation libraries)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Important Limits
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;useTransition&lt;/code&gt; is &lt;strong&gt;not magic&lt;/strong&gt;. It doesn't solve everything:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;50,000+ DOM elements will still be slow. You need virtualization (like &lt;code&gt;react-window&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;It's not a replacement for &lt;code&gt;React.memo&lt;/code&gt;, lazy loading, or code splitting&lt;/li&gt;
&lt;li&gt;It only helps with &lt;strong&gt;React updates&lt;/strong&gt;, not external operations&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Use only for genuinely heavy updates&lt;/strong&gt; - Don't wrap everything in &lt;code&gt;startTransition&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Combine with other optimizations&lt;/strong&gt; - Use &lt;code&gt;memo&lt;/code&gt;, &lt;code&gt;useMemo&lt;/code&gt;, and proper component structure&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Show feedback with isPending&lt;/strong&gt; - Let users know something is happening&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test with realistic data&lt;/strong&gt; - 10 items won't show the difference, 2,000 will&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;&lt;code&gt;useTransition&lt;/code&gt; is a powerful tool for building smooth, responsive UIs in React. It's not about making things faster—it's about making the &lt;strong&gt;right things fast&lt;/strong&gt; (user interactions) and letting the &lt;strong&gt;heavy things wait&lt;/strong&gt; (complex rendering).&lt;/p&gt;

&lt;h2&gt;
  
  
  💻 Complete Code
&lt;/h2&gt;

&lt;p&gt;Check out the full working project on my GitHub:&lt;br&gt;&lt;br&gt;
&lt;strong&gt;&lt;a href="https://github.com/DavideCannerozzi/react-use-transition-search" rel="noopener noreferrer"&gt;github.com/DavideCannerozzi/react-use-transition-search&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;




</description>
      <category>webdev</category>
      <category>react</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>Handling HTTP Requests in React with AbortController</title>
      <dc:creator>Davide Cannerozzi</dc:creator>
      <pubDate>Thu, 09 Oct 2025 12:29:32 +0000</pubDate>
      <link>https://dev.to/davidecannerozzi/handling-http-requests-in-react-with-abortcontroller-53jn</link>
      <guid>https://dev.to/davidecannerozzi/handling-http-requests-in-react-with-abortcontroller-53jn</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When building React applications, we often need to fetch data from APIs. But what happens if a component is removed from the page before the request finishes? &lt;br&gt;
Updating the state of an unmounted component can cause warnings or even memory leaks. &lt;br&gt;
To handle this safely, we use &lt;strong&gt;AbortController&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does “unmounting a component” mean?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Unmounting a component means React removes it from the DOM. This can happen when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The user navigates to another page or component.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Conditional rendering becomes false&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The parent component is removed or updated.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After unmounting, you should not update the component’s state. If a fetch request is still running and tries to update state, React shows this warning:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Warning: Can't perform a React state update on an unmounted component.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This warning indicates a potential memory leak. The fetch continues running even though the component is gone, wasting memory and CPU.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is AbortController and why use it?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AbortController is a browser API that allows you to cancel an ongoing fetch request.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Prevents warnings when a component unmounts before the request finishes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Avoids memory leaks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Saves network and system resources.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;When to use it:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;When fetching data in a component that can disappear quickly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When a user can cancel an action or navigate away.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For long-running or multiple concurrent fetch requests.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Practical Example: Custom useFetch Hook with AbortController&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Below is a complete example of a custom hook that uses AbortController to safely fetch data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useEffect, useState } from "react";

export interface AlbumDataProps {
  userId: number;
  id: number;
  title: string;
}

export const useFetch = () =&amp;gt; {
  const [data, setData] = useState&amp;lt;AlbumDataProps[]&amp;gt;([]);
  const [loading, setLoading] = useState&amp;lt;boolean&amp;gt;(true);
  const [error, setError] = useState&amp;lt;string | null&amp;gt;(null);

  useEffect(() =&amp;gt; {
    const controller = new AbortController(); // 1. Create controller

    const fetchData = async () =&amp;gt; {
      try {
        const response = await fetch(
          "https://jsonplaceholder.typicode.com/albums",
          { signal: controller.signal } // 2. Connect fetch to controller
        );
        const albums = await response.json();
        setData(albums);
      } catch (err) {
        if (err instanceof Error) {
          // 3. Ignore AbortError if request is canceled
          if (err.name === "AbortError") return;
          setError(err.message);
        } else {
          setError("Unknown error");
        }
      } finally {
        setLoading(false); // 4. End loading regardless of outcome
      }
    };

    fetchData();

    // 5. Cleanup: cancel fetch if the component unmounts
    return () =&amp;gt; controller.abort();
  }, []);

  return { data, loading, error };
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How it works&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;State management:&lt;/strong&gt; data, loading, and error track the request status.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;useEffect:&lt;/strong&gt; Runs the fetch when the component mounts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;AbortController:&lt;/strong&gt; Creates a controller to cancel fetch if needed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Signal connection:&lt;/strong&gt; The signal property links the controller to the fetch. Calling controller.abort() stops the fetch.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Error handling:&lt;/strong&gt; Regular errors are caught and saved in error. Abort errors are ignored intentionally.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cleanup function:&lt;/strong&gt; The return function cancels the fetch when the component unmounts.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Using the Hook in a React Application&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here’s how the hook works in a real app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useState } from "react";
import Button from "./components/Button/Button";
import CardsList from "./components/CardsList/CardsList";
import { useFetch } from "./hooks/useFetch";

function App() {
  const { data, loading, error } = useFetch();
  const [show, setShow] = useState(false);

  return (
    &amp;lt;&amp;gt;
      &amp;lt;Button setShow={setShow} show={show} /&amp;gt;
      {show &amp;amp;&amp;amp; (
        &amp;lt;div&amp;gt;
          {loading &amp;amp;&amp;amp; &amp;lt;p&amp;gt;Loading...&amp;lt;/p&amp;gt;}
          {error &amp;amp;&amp;amp; &amp;lt;p style={{ color: "red" }}&amp;gt;{error}&amp;lt;/p&amp;gt;}
          {!loading &amp;amp;&amp;amp; !error &amp;amp;&amp;amp; &amp;lt;CardsList albums={data} /&amp;gt;}
        &amp;lt;/div&amp;gt;
      )}
    &amp;lt;/&amp;gt;
  );
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Clicking the button toggles the list visibility.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When the list is shown, useFetch runs and fetches data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the user hides the list before fetch completes, AbortController safely cancels the request.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No warnings are shown, and the app remains stable.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using AbortController in React ensures that components can safely unmount without causing memory leaks or warnings.&lt;br&gt;
It’s essential for components that fetch data but can appear and disappear quickly, such as toggled lists, modals, or tabs.&lt;/p&gt;

&lt;p&gt;You can view the &lt;a href="https://github.com/DavideCannerozzi/Abort.Controller" rel="noopener noreferrer"&gt;complete project on GitHub&lt;/a&gt; (including App.tsx, Button, CardsList, and Card components) to explore the full implementation.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>🚀 React useState Lazy Initialization: A Complete Guide</title>
      <dc:creator>Davide Cannerozzi</dc:creator>
      <pubDate>Tue, 30 Sep 2025 11:47:28 +0000</pubDate>
      <link>https://dev.to/davidecannerozzi/react-usestate-lazy-initialization-a-complete-guide-1bck</link>
      <guid>https://dev.to/davidecannerozzi/react-usestate-lazy-initialization-a-complete-guide-1bck</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When building React applications, one of the most fundamental tools we use, is component state management through the useState hook. In most cases, we directly assign an initial value to our state, but this approach isn't always the most efficient solution. Sometimes, computing that initial value can be an expensive operation or simply unnecessary to repeat on every render.&lt;br&gt;
For these specific scenarios, React provides &lt;strong&gt;lazy initialization with useState&lt;/strong&gt;: a simple yet powerful technique that can significantly improve your application's performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Understanding Lazy Initialization&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Problem&lt;/strong&gt;&lt;br&gt;
In typical usage, you might write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [count, setCount] = useState(expensiveCalculation());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's the issue: expensiveCalculation() &lt;strong&gt;executes on every render&lt;/strong&gt;, even though we only need its result once. React ignores the value after initialization, but the function still runs, wasting resources.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Solution&lt;/strong&gt;&lt;br&gt;
With lazy initialization, pass a function instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [count, setCount] = useState(() =&amp;gt; expensiveCalculation());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now React executes expensiveCalculation() &lt;strong&gt;only once during the initial render and never again&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to Use It&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use lazy initialization when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reading from external sources&lt;/strong&gt;: localStorage, sessionStorage, cookies, or the DOM&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Expensive computations:&lt;/strong&gt; Parsing large JSON, complex calculations, or processing big datasets&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Complex data structures:&lt;/strong&gt; Building intricate initial configurations or nested objects&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Don't use it for simple values like useState(0), useState(""), or useState([]). The overhead isn't worth it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-World Example: Theme Persistence&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useEffect, useState } from "react";

function App() {
  const [theme, setTheme] = useState&amp;lt;string&amp;gt;(
    () =&amp;gt; localStorage.getItem("theme") || "light"
  );

  useEffect(() =&amp;gt; {
    localStorage.setItem("theme", theme);
  }, [theme]);

  return (
    &amp;lt;div
      style={{
        backgroundColor: theme === "dark" ? "#222" : "#fff",
        minHeight: "100vh",
      }}
    &amp;gt;
      &amp;lt;button onClick={() =&amp;gt; setTheme("light")}&amp;gt;Light Theme&amp;lt;/button&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; setTheme("dark")}&amp;gt;Dark Theme&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why Use Lazy Initialization?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Without it:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ❌ localStorage.getItem runs on EVERY render
const [theme, setTheme] = useState(localStorage.getItem("theme") || "light");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;With it:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ✅ localStorage.getItem runs ONLY ONCE
const [theme, setTheme] = useState(() =&amp;gt; localStorage.getItem("theme") || "light");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Benefits&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Performance:&lt;/strong&gt; Eliminates redundant localStorage reads on every re-render&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Efficiency:&lt;/strong&gt; Avoids synchronous I/O operations that slow down rendering&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clarity:&lt;/strong&gt; Explicitly shows initialization-only logic&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Without Lazy Initialization&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every time the component re-renders (button clicks, parent updates), you're:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Performing unnecessary localStorage reads&lt;/li&gt;
&lt;li&gt;Wasting CPU cycles on discarded results&lt;/li&gt;
&lt;li&gt;Degrading performance in frequently re-rendering components&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Lazy initialization with useState is a targeted optimization for expensive or external initialization operations. Use it when reading from localStorage, performing heavy calculations, or building complex data structures.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Remember:&lt;/strong&gt; Apply it only where it matters. Don't over-optimize simple values, but don't ignore it when dealing with costly operations.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>reactjsdevelopment</category>
      <category>webdev</category>
    </item>
    <item>
      <title>HTML5 | Build a Widget with &lt;details&gt; and &lt;summary&gt; tag!</title>
      <dc:creator>Davide Cannerozzi</dc:creator>
      <pubDate>Fri, 11 Feb 2022 11:08:59 +0000</pubDate>
      <link>https://dev.to/davidecannerozzi/html5-build-a-widget-with-and-tag-1a82</link>
      <guid>https://dev.to/davidecannerozzi/html5-build-a-widget-with-and-tag-1a82</guid>
      <description>&lt;p&gt;The beauty of being a programmer is that we always have new things to learn and test.&lt;br&gt;
Surfing the internet, I came across two HTML tags that I didn't know.&lt;br&gt;
I immediately wanted to test them, and now I would like to write an article.&lt;/p&gt;

&lt;p&gt;I am talking about:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;details&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;summary&amp;gt;&lt;/code&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These two tags were recently introduced with &lt;strong&gt;HTML 5.1&lt;/strong&gt;, and they are helpful if we want to create a widget that you can open and close whenever you want.&lt;/p&gt;

&lt;p&gt;The summary tag is used along with the details tag.&lt;/p&gt;

&lt;p&gt;Open your code editor and type&lt;br&gt;
&lt;/p&gt;

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

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

&lt;/div&gt;



&lt;p&gt;A cute triangle and the word Details will appear on our web page.&lt;br&gt;
If we click on the triangle or the text, you will see that the small triangle will change position indicating the bottom, ready to show us some content that we have not yet entered.&lt;/p&gt;

&lt;p&gt;Let's say that we don't like the word details, and we want a different text for our project.&lt;/p&gt;

&lt;p&gt;How do we change it?&lt;br&gt;
Easy, using the tag summary.&lt;/p&gt;

&lt;p&gt;Between the details tag put the summary tag and the text you want to output. &lt;br&gt;
In my case, I will write &lt;strong&gt;Show More&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
   &amp;lt;details&amp;gt;
      &amp;lt;summary&amp;gt;Show More&amp;lt;/summary&amp;gt;
   &amp;lt;/details&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now it's time to show something inside the widget.&lt;/p&gt;

&lt;p&gt;Below the summary tag, we put the content we want to show when the user clicks on the arrow.&lt;/p&gt;

&lt;p&gt;You can put any HTML tag you want, h1, h2, a list of elements, and so on.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
   &amp;lt;details&amp;gt;
      &amp;lt;summary&amp;gt;Show More&amp;lt;/summary&amp;gt;
      &amp;lt;p&amp;gt;Hi Developer!&amp;lt;/p&amp;gt;
   &amp;lt;/details&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The details tag can have a default value ( closed ) and an open value.&lt;br&gt;
The open value will show the content without clicking on the arrow&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
   &amp;lt;details open&amp;gt;
      &amp;lt;summary&amp;gt;Show More&amp;lt;/summary&amp;gt;
      &amp;lt;p&amp;gt;Hi Developer!&amp;lt;/p&amp;gt;
   &amp;lt;/details&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that we know more about these two tags,let's build a simple FAQ widget.&lt;/p&gt;

&lt;p&gt;Html:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
   &amp;lt;h1&amp;gt;FAQ&amp;lt;/h1&amp;gt;
   &amp;lt;details&amp;gt;
      &amp;lt;summary&amp;gt;What is HTML?&amp;lt;/summary&amp;gt;
      &amp;lt;p&amp;gt;The HyperText Markup Language, or HTML is the standard markup language for documents designed to be displayed in a web browser.!&amp;lt;/p&amp;gt;
   &amp;lt;/details&amp;gt;
   &amp;lt;details&amp;gt;
      &amp;lt;summary&amp;gt;What is CSS?&amp;lt;/summary&amp;gt;
      &amp;lt;p&amp;gt;Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language such as HTML.&amp;lt;/p&amp;gt;
   &amp;lt;/details&amp;gt;
   &amp;lt;details&amp;gt;
      &amp;lt;summary&amp;gt;What is Javascript?&amp;lt;/summary&amp;gt;
      &amp;lt;p&amp;gt;JavaScript, often abbreviated JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS&amp;lt;/p&amp;gt;
   &amp;lt;/details&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Css:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body{
   width:80%;
   margin:2rem auto;
   font-family:'Courier New', Courier, monospace;
}
h1{
   text-align: center;
   font-size: 3rem;
}
summary{
   padding:1.2rem;
   background-color: rgb(250, 179, 49);
   margin-top:1.5rem;
   font-weight: 600;
}

p{ padding:1rem }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&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.amazonaws.com%2Fuploads%2Farticles%2Fe70ssdl7d18pr1zpz4qm.jpg" 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.amazonaws.com%2Fuploads%2Farticles%2Fe70ssdl7d18pr1zpz4qm.jpg" alt="FAQ Project html" width="800" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All this without Javascript!!&lt;/p&gt;

</description>
      <category>html</category>
      <category>css</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>The useState Hook!</title>
      <dc:creator>Davide Cannerozzi</dc:creator>
      <pubDate>Tue, 08 Feb 2022 12:54:30 +0000</pubDate>
      <link>https://dev.to/davidecannerozzi/the-usestate-hook-471b</link>
      <guid>https://dev.to/davidecannerozzi/the-usestate-hook-471b</guid>
      <description>&lt;p&gt;Before React implemented the Hooks, changing state was only possible inside class components.&lt;br&gt;
From &lt;strong&gt;React 16.8&lt;/strong&gt;, we can change the state inside a functional component.&lt;/p&gt;

&lt;p&gt;React offers many built-in Hooks:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;useState,&lt;/li&gt;
&lt;li&gt;useReducer,&lt;/li&gt;
&lt;li&gt;useEffect&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;and much more!&lt;/p&gt;

&lt;p&gt;This article will show you how to use the &lt;strong&gt;useState Hook&lt;/strong&gt; inside a functional component.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Before continuing, make sure that you know at least some basics of React and Javascript ES6.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;useState() Hook&lt;/strong&gt; is just a simple Javascript function that returns two values.&lt;/p&gt;

&lt;p&gt;We can store any value type( array, numbers, strings, objects, booleans ).&lt;/p&gt;

&lt;p&gt;To make the concept easier to understand, I will build a simple App where the data changes when the user clicks on a button.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. CREATE A FUNCTIONAL COMPONENT COUNTER.JSX&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In React you can define a functional component using the arrow function syntax&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Counter =  () =&amp;gt; {
   return(
     &amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;
   )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Counter(){
    return(
      &amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;
    )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this article, I will use the arrow function syntax.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;IMPORT THE useState HOOK FROM THE REACT LIBRARY&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState } from ‘react‘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside the Counter component, let’s create a button and a paragraph.&lt;/p&gt;

&lt;p&gt;The button will increment the counter inside the paragraph tag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  return(
    &amp;lt;div className=‘App‘&amp;gt;
      &amp;lt;p&amp;gt;Counter:&amp;lt;/p&amp;gt;
      &amp;lt;button&amp;gt;Increment Counter&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. SET THE STATE&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that we have our component, we can write the useState() Hook, using the array destructuring ES6 syntax.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The first value( counter ) is the current state, the second value ( setCounter) is the function that we will invoke to update the state.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The argument inside the useState is set to 1, which means that the counter now is equal to 1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  return(
     const [counter,setCounter] = useState(1)
    &amp;lt;div&amp;gt;
      &amp;lt;p&amp;gt;Counter:{ counter }&amp;lt;/p&amp;gt;
      &amp;lt;button&amp;gt;Increment Counter&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. OUTPUT AND INCREMENT THE STATE&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you are familiar with javascript, this might be easy for you.&lt;/p&gt;

&lt;p&gt;First of all, we pass the onClick events to the button.&lt;br&gt;
The onClick event take a function where we use the setCounter to update the initial counter.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Remember: in React we use curly braces to evaluate a Javascript expression, a variable, a sum of two numbers, a function, and so on.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Counter = () =&amp;gt; {

const[counter,setCounter] = useState(1)

return(
    &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;useState Hook – React&amp;lt;/h1&amp;gt;
      &amp;lt;p&amp;gt;Counter: { counter }&amp;lt;/p&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; setCounter( counter + 1 )}&amp;gt;Increment 
      &amp;lt;/button&amp;gt;  
    &amp;lt;/div&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In our case counter was equal to 1, and we just added + 1 to increment it by one.&lt;/p&gt;

&lt;p&gt;Click on the button and you will see!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Good to Know:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;You can't use Hooks inside a class components&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;You can set as much useState as you need inside your component&lt;/em&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to Center A Div With Flexbox</title>
      <dc:creator>Davide Cannerozzi</dc:creator>
      <pubDate>Mon, 07 Feb 2022 11:08:10 +0000</pubDate>
      <link>https://dev.to/davidecannerozzi/how-to-center-a-div-with-flexbox-2g73</link>
      <guid>https://dev.to/davidecannerozzi/how-to-center-a-div-with-flexbox-2g73</guid>
      <description>&lt;p&gt;Before Flexbox, centering elements in CSS was a little bit frustrating. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WHAT IS FLEXBOX?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Flexbox is a CSS3 layout model that allows developers to build one dimension layout.&lt;/p&gt;

&lt;p&gt;First of all, you need to have: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;a flex container (.wrapper) &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;flex items (.flex-item)&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
    &amp;lt;div class=”wrapper”&amp;gt;
        &amp;lt;div class=”flex-item”&amp;gt;&amp;lt;/div&amp;gt;
        &amp;lt;div class=”flex-item”&amp;gt;&amp;lt;/div&amp;gt;
        &amp;lt;div class=”flex-item”&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I will give some style to the flex items, to show them on the web page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.flex-item{
  border:1px solid red;
  height:30px;
  width:30px;
}

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

&lt;/div&gt;



&lt;p&gt;Without giving any css property to the wrapper container, the flex items will display one below the other.&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.amazonaws.com%2Fuploads%2Farticles%2Fvbsui00mo0kwtbbcb9i3.jpg" 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.amazonaws.com%2Fuploads%2Farticles%2Fvbsui00mo0kwtbbcb9i3.jpg" alt="flexitems" width="625" height="481"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But if we give the property display:flex to the container see what happen. ​&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.wrapper{
 display:flex
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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.amazonaws.com%2Fuploads%2Farticles%2Fdgqvg1sv0w9dzfmhb0m6.jpg" 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.amazonaws.com%2Fuploads%2Farticles%2Fdgqvg1sv0w9dzfmhb0m6.jpg" alt="flexcontainer" width="637" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Flex Items are now displayed horizontally but not centered. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How To Center Horizontally&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that we have our flex-container, we can learn how to center the flex-items horizontally. &lt;br&gt;
The only thing to do is set the &lt;code&gt;justify-content:center&lt;/code&gt; props to the flex-container.&lt;br&gt;
The justify-content property allows us to position the flex-item along the main-axis of the flex-container.&lt;br&gt;
As you can see, the divs are now centered horizontally inside the container.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.wrapper{
    display:flex;
    justify-content:center
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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.amazonaws.com%2Fuploads%2Farticles%2F4l36ctua0f2t4nyc2w4q.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.amazonaws.com%2Fuploads%2Farticles%2F4l36ctua0f2t4nyc2w4q.png" alt="flexitemcenter" width="800" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How To Center Vertically&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of the justify-content property, you have to use the &lt;code&gt;align-items:center&lt;/code&gt; property.&lt;br&gt;
This property allow us to position the flex-items along the cross-axis.&lt;/p&gt;

&lt;p&gt;You are probably notice that the flex item didn’t move from the initial position.&lt;/p&gt;

&lt;p&gt;Why?&lt;br&gt;
To center an element vertically, we should give a height to the flex container.&lt;br&gt;
Let’s make the container 100vh which means 100% of the viewport height.&lt;br&gt;
Now the divs are centered vertically. &lt;/p&gt;

&lt;p&gt;Well Done!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.wrapper{
    display:flex; 
    height:100vh;
    align-items:center
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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.amazonaws.com%2Fuploads%2Farticles%2Fkycw3onmbat2xzkb0nfl.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.amazonaws.com%2Fuploads%2Farticles%2Fkycw3onmbat2xzkb0nfl.png" alt="flexitemcentervertically" width="800" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How To Center Vertically And Horizontally .&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since we already know how to center vertically and horizontally, you can easily guess how to do it. &lt;br&gt;
We need to use both align-content and justify-content property.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Remember: set a height to the container; otherwise, it will not work.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.wrapper{
    display:flex;
    height:100vh;
    justify-content:center;
    align-items:center
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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.amazonaws.com%2Fuploads%2Farticles%2Fvhi90i3lsz3jmik0pud0.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.amazonaws.com%2Fuploads%2Farticles%2Fvhi90i3lsz3jmik0pud0.png" alt="centerflexbox" width="800" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Flexbox is a powerful tool that every front-end developer should master.&lt;/p&gt;

&lt;p&gt;As you can see from &lt;a href="https://caniuse.com/flexbox" rel="noopener noreferrer"&gt;caniuse.com&lt;/a&gt;, it is very well supported by all modern browsers.&lt;/p&gt;

</description>
      <category>css</category>
      <category>flexbox</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Array Destructuring</title>
      <dc:creator>Davide Cannerozzi</dc:creator>
      <pubDate>Wed, 02 Feb 2022 12:53:13 +0000</pubDate>
      <link>https://dev.to/davidecannerozzi/array-destructuring-ifo</link>
      <guid>https://dev.to/davidecannerozzi/array-destructuring-ifo</guid>
      <description>&lt;p&gt;Every Front end developer, sooner or later, will have to deal with arrays and objects.&lt;/p&gt;

&lt;p&gt;Extrapolating data from an array may require several lines of code, but with the new es6 destructuring features, we can achieve the same goal with fewer lines of code.&lt;/p&gt;

&lt;p&gt;In this article, I am going to teach you about Array Destructuring.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;DESTRUCTURING IS A TOPIC YOU MUST KNOW IF YOU WANT TO BECOME A REACT DEVELOPER&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To extract values from an array and push them into a variable,  you would proceed like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const dogs = [‘Oliver’,’Winston’,’Carl’]

const first = dogs[0]
const second = dogs[1]
const third = dogs[2]

console.log( first, second, third ) 
Output: Oliver, Winston, Carl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything works fine, but It can require many lines of code.&lt;/p&gt;

&lt;p&gt;Now, Let’s see the process with the destructuring features.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const dogs = ['oliver', 'winnie', 'carl'];
const [first,second,third ] = dogs;

console.log(first,second,third)
Output: Oliver Winnie Carl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside the square brackets, we declare the variables followed by an equal sign and the name of the array we want to destruct.&lt;/p&gt;

&lt;p&gt;Each variable should match with the index of the element inside the array.&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.amazonaws.com%2Fuploads%2Farticles%2F7q8ypqcvh6g00jwdruk6.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.amazonaws.com%2Fuploads%2Farticles%2F7q8ypqcvh6g00jwdruk6.png" alt="Array Destructuring" width="800" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HOW TO SKIP ITEMS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What if you would like to output only the fourth array element?&lt;br&gt;
You only have to use the comma, one comma skips one item in the array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1,2,3,4]

const [, , ,num] = numbers

console.log(num)

Output : 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;DESTRUCTURING AND THE SPREAD OPERATOR&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If we want to get the rest of the elements from the initial array, we can use the … rest operator, another powerful ES6 feature.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1,2,3,4,5,6,7,8,9,10]

const [first,second,…rest] = numbers

console.log(first) Output: 1
console.log(second) Output: 2
console.log(rest)    Output: [3,4,5,6,7,8,9,10]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;DEFAULT VALUES&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With Destructuring, we can use default values.&lt;br&gt;
If a variable has no value or is undefined, we can use the equal sign to provide a fallback value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const dogs = ['dave','carl',undefined,'winston']

const [first,second,third='oliver',fourth] = dogs

console.log(first)
console.log(second) 
console.log(third)  
console.log(fourth) 

Output: dave, carl,oliver,winston
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1,2,3]

const [a,b,c,d = 4] = numbers

console.log(a,b,c,d)

Output: 1 , 2 , 3 , 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will use this feature often if your goal is to become a react developer.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Learn create-react-app</title>
      <dc:creator>Davide Cannerozzi</dc:creator>
      <pubDate>Tue, 01 Feb 2022 10:46:04 +0000</pubDate>
      <link>https://dev.to/davidecannerozzi/learn-create-react-app-a1j</link>
      <guid>https://dev.to/davidecannerozzi/learn-create-react-app-a1j</guid>
      <description>&lt;p&gt;Let's get straight to the point.&lt;br&gt;
If you want to become a &lt;a href="https://reactjs.org/" rel="noopener noreferrer"&gt;React&lt;/a&gt; Developer, you should know create-react-app&lt;/p&gt;

&lt;p&gt;but...&lt;/p&gt;
&lt;h2&gt;
  
  
  WHAT IS CREATE-REACT-APP
&lt;/h2&gt;

&lt;p&gt;Create-react-app is a tool built by Facebook to help set up all the tools you need for your React applications.&lt;/p&gt;

&lt;p&gt;Before we dive into this fantastic tool, be sure to know Javascript ES6 and to have node.js installed on your computer.&lt;/p&gt;

&lt;p&gt;CSS and HTML are also required to build a react app.&lt;/p&gt;

&lt;p&gt;Now it's time to open your terminal and type the command npx create-react-app followed by a space and your application's name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app myapp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the installation is completed, you will get the success message in the terminal.&lt;/p&gt;

&lt;p&gt;Navigate in your project folder and run the command &lt;code&gt;npm start&lt;/code&gt;&lt;br&gt;
to start the development server on localhost:3000.&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.amazonaws.com%2Fuploads%2Farticles%2Fz6hoki8q26r7nwiotnq1.jpg" 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.amazonaws.com%2Fuploads%2Farticles%2Fz6hoki8q26r7nwiotnq1.jpg" alt="react-localhost" width="781" height="703"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open the project folder in your text editor and look at the folder structure created by create-react-app.&lt;/p&gt;

&lt;p&gt;If it is your first time using a Javascript library, you can be intimidated by the number of files inside your project folder.&lt;/p&gt;

&lt;p&gt;Let’s take a look at the most important files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;THE PACKAGE.JSON FILE&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It Contains the dependencies needed to build your project, and it also describes your application, such as the name and the version.&lt;br&gt;
You can easily change the name of your App inside this file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;THE SRC FOLDER&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We will put all the JS and CSS files necessary to build the UI and your application's functionality inside this folder.&lt;br&gt;
All the components we want to create must be inside the &lt;strong&gt;src folder.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The App.js file is the wrapper component of the App. &lt;br&gt;
It's the container for all other React components.&lt;br&gt;
The index.js file tells React where to render the App component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;THE PUBLIC FOLDER&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the public folder, we will focus on the index.html file.&lt;br&gt;
This file contains plain HTML.&lt;br&gt;
React will inject the code inside the div with the id 'root' via the render function inside the &lt;strong&gt;index.js&lt;/strong&gt; file.&lt;/p&gt;

&lt;p&gt;Try to edit the App.js file, and let's see what happens!&lt;br&gt;
Delete the code inside the wrapper div and also remove the logo.svg file from our project and don't forget to remove the import statement in the App.js.&lt;/p&gt;

&lt;p&gt;Going back to the browser, you will see a completely blank page&lt;/p&gt;

&lt;p&gt;Inside the App.js file, try to write an H1 HTML tag between the div with the class App.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function App() {
  return (
    &amp;lt;div className="App"&amp;gt;
     &amp;lt;h1&amp;gt;Learning React&amp;lt;/h1&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;React will automatically update the page.&lt;/p&gt;

&lt;p&gt;Back to the browser, and you will notice a nice **LEARNING REACT **header displayed on your page&lt;/p&gt;

&lt;p&gt;The setup is finished, you are ready to code your App.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
