<?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: Daniel Bellmas</title>
    <description>The latest articles on DEV Community by Daniel Bellmas (@danielbellmas).</description>
    <link>https://dev.to/danielbellmas</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%2F710015%2F0ad6ff73-fad6-40c2-8ca5-c29ff1133cc1.jpeg</url>
      <title>DEV Community: Daniel Bellmas</title>
      <link>https://dev.to/danielbellmas</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/danielbellmas"/>
    <language>en</language>
    <item>
      <title>Configure Your Terminal With Shortcut keys</title>
      <dc:creator>Daniel Bellmas</dc:creator>
      <pubDate>Sat, 09 Mar 2024 10:28:03 +0000</pubDate>
      <link>https://dev.to/danielbellmas/configure-your-terminal-with-shortcut-keys-539f</link>
      <guid>https://dev.to/danielbellmas/configure-your-terminal-with-shortcut-keys-539f</guid>
      <description>&lt;p&gt;I couldn't delete a whole line with my regular shortcut:&lt;br&gt;
&lt;code&gt;Cmd&lt;/code&gt; + &lt;code&gt;Backspace&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To enable those kind of shortcuts in &lt;code&gt;iterm2&lt;/code&gt; we need to edit the prefrences:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Preferences&lt;/code&gt; &amp;gt; &lt;code&gt;Keys&lt;/code&gt; &amp;gt; &lt;code&gt;Show/hide all windows with a system-wide hotkey&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fidl845ga0suv71t7rjx8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fidl845ga0suv71t7rjx8.png" alt="Image description" width="800" height="477"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Resource
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://apple.stackexchange.com/questions/256259/how-to-open-terminal-in-mac-using-keyboard-shortcut#:~:text=add%20a%20shortcut%3A-,iTerm%202,-iTerm%202%20has"&gt;Stack exchange&lt;/a&gt;&lt;/p&gt;

</description>
      <category>terminal</category>
      <category>mac</category>
      <category>productivity</category>
      <category>configuration</category>
    </item>
    <item>
      <title>Music Trick For Mac Users</title>
      <dc:creator>Daniel Bellmas</dc:creator>
      <pubDate>Sat, 09 Mar 2024 10:11:31 +0000</pubDate>
      <link>https://dev.to/danielbellmas/music-trick-for-mac-users-1m89</link>
      <guid>https://dev.to/danielbellmas/music-trick-for-mac-users-1m89</guid>
      <description>&lt;p&gt;For mac users, the pain of pressing the play button and accidentally triggering the apple music app is very familiar.&lt;br&gt;
You must've tried to delete it but realized it can't be done.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution
&lt;/h2&gt;

&lt;p&gt;Of course there's a smarter person that already solved this issue - &lt;code&gt;noTunes&lt;/code&gt; 🙏&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Download&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  brew &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--cask&lt;/span&gt; notunes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Set noTunes to launch at startup&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Navigate to &lt;code&gt;System Settings&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Select &lt;code&gt;General&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Select &lt;code&gt;Login Items&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Click the &lt;code&gt;+&lt;/code&gt; under &lt;code&gt;Open at Login&lt;/code&gt; and select &lt;code&gt;noTunes&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  And...that's it!
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If you wanna change the default music player you can simply run the command below and don't forget to replace &lt;code&gt;YOUR_MUSIC_APP&lt;/code&gt; with the name of your music app.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;defaults write digital.twisted.noTunes replacement /Applications/YOUR_MUSIC_APP.app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, I replaces mine with the &lt;code&gt;YouTube music&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you wanna hide the menu bar icon, just right click the menu bar icon and click Hide Icon.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Resource
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/tombonez/noTunes?tab=readme-ov-file#notunes"&gt;https://github.com/tombonez/noTunes?tab=readme-ov-file#notunes&lt;/a&gt;&lt;/p&gt;

</description>
      <category>music</category>
      <category>productivity</category>
      <category>programming</category>
      <category>mac</category>
    </item>
    <item>
      <title>'return await' in a try/catch</title>
      <dc:creator>Daniel Bellmas</dc:creator>
      <pubDate>Sat, 09 Dec 2023 15:59:02 +0000</pubDate>
      <link>https://dev.to/danielbellmas/return-await-in-a-trycatch-4oh</link>
      <guid>https://dev.to/danielbellmas/return-await-in-a-trycatch-4oh</guid>
      <description>&lt;p&gt;This might sound weird to you, the first thing that comes to mind is: 'Eslint will tell me to remove the await, there is no need for an await after a return'&lt;/p&gt;

&lt;p&gt;But the case is a different when we wrap our promise in a &lt;code&gt;try/catch&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;waitAndMaybeReject&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &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="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="s1"&gt;caught&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This also applies when we don't need to return resolved value of the promise, &lt;strong&gt;we always need to await it if the returned promise is inside a &lt;code&gt;try/catch&lt;/code&gt; and we want to catch the error&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;By returning a promise, we’re deferring its result, so our catch block never runs.&lt;br&gt;
This also happens, when not awaiting a promise (regardless if we return or not).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Only outside of try/catch blocks, &lt;code&gt;return await&lt;/code&gt; is redundant. There’s even an &lt;a href="https://eslint.org/docs/latest/rules/no-return-await"&gt;Eslint rule&lt;/a&gt;, but this rule allows a return if it's in &lt;code&gt;try/catch&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h2&gt;
  
  
  Bonus🔥
&lt;/h2&gt;

&lt;p&gt;If you want to print something after a return statement, instead of temporaraly creating a variable, printing and then returning, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;foo&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;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;after fetch&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="nx"&gt;res&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;We can wrap the return with a try and finallly (unless you need to print the resolved value of the promise of course), like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;after fetch&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>node</category>
      <category>eslint</category>
      <category>webdev</category>
    </item>
    <item>
      <title>KillNode Script For React Apps</title>
      <dc:creator>Daniel Bellmas</dc:creator>
      <pubDate>Sat, 09 Dec 2023 15:32:57 +0000</pubDate>
      <link>https://dev.to/danielbellmas/killnode-script-for-react-apps-3831</link>
      <guid>https://dev.to/danielbellmas/killnode-script-for-react-apps-3831</guid>
      <description>&lt;p&gt;TL;DR&lt;br&gt;
This is a script to delete a running node process, if one exists.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="nv"&gt;lsof_output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;lsof &lt;span class="nt"&gt;-i&lt;/span&gt; :3000&lt;span class="si"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$lsof_output&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nv"&gt;node_line&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$lsof_output&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"node"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$node_line&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nv"&gt;pid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$node_line&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $2}'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;

    &lt;span class="c"&gt;# Kill the Node.js process with SIGKILL (9)&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Killing Node.js process with PID &lt;/span&gt;&lt;span class="nv"&gt;$pid&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;kill&lt;/span&gt; &lt;span class="nt"&gt;-9&lt;/span&gt; &lt;span class="nv"&gt;$pid&lt;/span&gt;

    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Node.js process killed."&lt;/span&gt;
  &lt;span class="k"&gt;else
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"No Node.js process found on port 3000."&lt;/span&gt;
  &lt;span class="k"&gt;fi
else
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"No process is listening on port 3000."&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's very useful when running &lt;code&gt;npm start&lt;/code&gt; to spin up a React app and you get a &lt;code&gt;Port 3000 is already in use&lt;/code&gt; message.&lt;/p&gt;

&lt;p&gt;You can also pair it with the &lt;code&gt;npm start&lt;/code&gt; command right after it for a better experience. If the port is not in use the script will not do anything.&lt;/p&gt;

&lt;p&gt;I went ahead and created an alias for even more convenience, and to do that follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your &lt;code&gt;.zshrc&lt;/code&gt; or &lt;code&gt;.bashrc&lt;/code&gt; with: &lt;code&gt;code ~/.zshrc&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;alias killnode="killnode.sh &amp;amp;&amp;amp; npm start"&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Run it from you app's folder&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Enjoy 🦾 &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>terminal</category>
      <category>productivity</category>
      <category>bash</category>
    </item>
    <item>
      <title>Spread Multiple Props With This Syntax</title>
      <dc:creator>Daniel Bellmas</dc:creator>
      <pubDate>Fri, 15 Sep 2023 10:12:23 +0000</pubDate>
      <link>https://dev.to/danielbellmas/spread-multiple-props-with-this-syntax-3e92</link>
      <guid>https://dev.to/danielbellmas/spread-multiple-props-with-this-syntax-3e92</guid>
      <description>&lt;p&gt;In React, when working with components, you might encounter scenarios where you want to conditionally pass multiple props based on a certain condition. Fortunately, there's a concise syntax that allows you to do just that.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Conditional Spread Syntax
&lt;/h2&gt;

&lt;p&gt;Imagine you have a React component named &lt;code&gt;&amp;lt;Button /&amp;gt;&lt;/code&gt;, and you want to conditionally pass multiple props (&lt;code&gt;color&lt;/code&gt; and &lt;code&gt;size&lt;/code&gt;) to it based on some condition. Here's how you can achieve this using the conditional spread syntax:&lt;br&gt;
&lt;/p&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="nx"&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;isLoading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setIsLoading&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&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="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* Conditional spreading of props */&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;Button&lt;/span&gt; &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;...(&lt;/span&gt;&lt;span class="nx"&gt;isLoading&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;primary&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;large&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;
        Click me
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Button&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="nt"&gt;div&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;In this example:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We first define a &lt;code&gt;condition&lt;/code&gt; in this example it's &lt;code&gt;isLoading&lt;/code&gt; that determines whether we want to pass the additional props.&lt;/li&gt;
&lt;li&gt;We define the &lt;code&gt;color&lt;/code&gt; and &lt;code&gt;size&lt;/code&gt; variables, which represent the props we want to conditionally pass to the &lt;code&gt;&amp;lt;Button /&amp;gt;&lt;/code&gt; component.&lt;/li&gt;
&lt;li&gt;Within the JSX, we use the conditional spread syntax:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;{...(isLoading &amp;amp;&amp;amp; { color, size })}&lt;/code&gt;. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the &lt;code&gt;condition&lt;/code&gt; is &lt;code&gt;true&lt;/code&gt;, it spreads the object &lt;code&gt;{ color, size }&lt;/code&gt; as props to the &lt;code&gt;&amp;lt;Button /&amp;gt;&lt;/code&gt; component.&lt;/li&gt;
&lt;li&gt;If the &lt;code&gt;condition&lt;/code&gt; is &lt;code&gt;false&lt;/code&gt;, no props are spread, and the &lt;code&gt;&amp;lt;Button /&amp;gt;&lt;/code&gt; component receives only its default props.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;We render the &lt;code&gt;&amp;lt;Button /&amp;gt;&lt;/code&gt; component with the conditional props, and it will have the additional properties (&lt;code&gt;color&lt;/code&gt; and &lt;code&gt;size&lt;/code&gt;) only when the condition is met.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This technique provides a clean and concise way to conditionally spread multiple props onto a component, making your code more readable and maintainable when you have &lt;strong&gt;varying prop requirements based on specific conditions&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>typescript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Prefix Unused Variables With Underscore</title>
      <dc:creator>Daniel Bellmas</dc:creator>
      <pubDate>Fri, 15 Sep 2023 09:52:33 +0000</pubDate>
      <link>https://dev.to/danielbellmas/prefix-unused-variables-with-underscore-3h2d</link>
      <guid>https://dev.to/danielbellmas/prefix-unused-variables-with-underscore-3h2d</guid>
      <description>&lt;p&gt;We're always on the lookout for clever ways to make our code more readable and maintainable.&lt;br&gt;
Today, let's explore a quick and fun little trick that involves prefixing unused variables in function arguments with an underscore (_). This simple technique can help us signal to others (and ourselves) that these variables are irrelevant to the current task at hand.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We can also only use an underscore without any variable. Still, the downside is that it can be confusing as to what this variable that we're ignoring is, and not as descriptive. (Eslint too will understand this syntax)&lt;/p&gt;
&lt;/blockquote&gt;



&lt;p&gt;Imagine you're working on a web application that fetches data from an API. The API response includes a callback function with several arguments, but you're only interested in the first and last argument. Here's how the underscore prefix can help:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fetchData&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;_statusCode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;headers&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="c1"&gt;// Process 'data' and ignore '_statusCode'&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;headers&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;In this example, you're using the &lt;code&gt;api.fetchData&lt;/code&gt; function, which provides a callback with three arguments. By prefixing _statusCode with an underscore, you make it clear that you're intentionally ignoring this variable in your callback function. This practice enhances code readability and helps others understand your coding intentions.&lt;/p&gt;




&lt;h3&gt;
  
  
  Final Thoughts
&lt;/h3&gt;

&lt;p&gt;The underscore prefix is a valuable convention for callbacks that provide more arguments than necessary. It simplifies code readability and helps convey your coding intentions clearly. So, the next time you encounter surplus callback arguments, don't hesitate to prefix the unused ones with an underscore. Your fellow developers (and future self) will appreciate the clarity and maintainability it brings to your code! 🚀&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>cleancode</category>
      <category>tip</category>
    </item>
    <item>
      <title>Dependent Function Arguments With TypeScript</title>
      <dc:creator>Daniel Bellmas</dc:creator>
      <pubDate>Fri, 04 Nov 2022 19:01:03 +0000</pubDate>
      <link>https://dev.to/danielbellmas/dependent-function-arguments-with-typescript-4epn</link>
      <guid>https://dev.to/danielbellmas/dependent-function-arguments-with-typescript-4epn</guid>
      <description>&lt;p&gt;Typescript is an excellent tool for making sure we have fewer bugs by having the IDE complete our code in accordance with the types we defined.&lt;/p&gt;

&lt;p&gt;Here we'll see how to use mapped types to have more control over our functions while making them more readable for the next developer that uses those functions.&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="kr"&gt;enum&lt;/span&gt; &lt;span class="nx"&gt;DATA_TYPE&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;STYLE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;STYLE&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;THEME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;THEME&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="kr"&gt;enum&lt;/span&gt; &lt;span class="nx"&gt;STYLE_PROPERTY&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;ID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ID&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;NAME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;NAME&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;DATE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;DATE&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="kr"&gt;enum&lt;/span&gt; &lt;span class="nx"&gt;THEME_PROPERTY&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;ID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ID&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;NAME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;NAME&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;LAST_MODIFIED&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;LAST_MODIFIED&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;ORIGIN_THEME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ORIGIN_THEME&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;PROTECTED&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;PROTECTED&lt;/span&gt;&lt;span class="dl"&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;ListGetTypeMap&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;DATA_TYPE&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;STYLE&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt; &lt;span class="nx"&gt;STYLE_PROPERTY&lt;/span&gt;&lt;span class="p"&gt;[];&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;DATA_TYPE&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;THEME_PROPERTY&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;ObjectGetTypeMap&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;DATA_TYPE&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;STYLE&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;STYLE_PROPERTY&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&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="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;STYLE_PROPERTY&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="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="nx"&gt;STYLE_PROPERTY&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DATE&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="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;DATA_TYPE&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="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;THEME_PROPERTY&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&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="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;THEME_PROPERTY&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="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="nx"&gt;THEME_PROPERTY&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;LAST_MODIFIED&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="nx"&gt;THEME_PROPERTY&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ORIGIN_THEME&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="nx"&gt;THEME_PROPERTY&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PROTECTED&lt;/span&gt;&lt;span class="p"&gt;]?:&lt;/span&gt; &lt;span class="nx"&gt;boolean&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="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;TGetProperty&lt;/span&gt; &lt;span class="o"&gt;=&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="kd"&gt;extends&lt;/span&gt; &lt;span class="kr"&gt;keyof&lt;/span&gt; &lt;span class="nx"&gt;ListGetTypeMap&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;type&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;keys&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ListGetTypeMap&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;ObjectGetTypeMap&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Try it out in &lt;a href="https://www.typescriptlang.org/play?#code/MYewdgzgLgBApmArgWxgEQIIBUMH0sCaACgKIwDeAUDDAMoCKAqiSQFpkC8MA5A82yW4AaajCwAJEgFlOPCdMGUAvpUqhIsBCjpMW7XEQBKAeVKHCFUQEk0MLtxvDRAOQwy7PVzKc1MWWdx+iipq4NDwSKjyMgYmZhZUNDYeDmg+MF4BmekAMhi0WLhSxmhWAGJWJLb2eQVFJeWVaSI0xoZWAOJWzviS7vZtnd29CulGxv4Awv7VPONTM9zKqnAAHgAOIABOsACWYFBwWwBmAIbAcDA5u9AdcFBYAJ7rcFKn65Y0ANp+eISkADo+HoSABdABcOn4+nG8QIX1BAG5RD9sH9iCQAdEwZDsbFTCRzPCkctKGtNjsYPtDidzpdjAAjABWcGAUDuD2er3enxgqJw+AxQN0AghvO+wIE+LhAJsoIA-JDoFt9gBzZE0CUimFxQmEAGZBVKqAqsDq0Ra6EkaV6ggAoJGmDKtUamBKV389GA7FixKar542G22VoR3Os2u76B3VEg1uMGKp0ml0WvnRgmx2qFYqlCpVMPJiOpgN9a1B2ODLo9H2J8PmzVp0s22PzEjTfOJhkgEAAGzgpzArvdpPJ21gUC5Yg5RC2IBeO0eHgAPFh4KtDmAACYQGAAazgjxAxyuN3Z9yeLze6wAfAAKCcvXFCPcHiCQ663c9cq8B0EASjsa8YEZFk2Q5C9uXWX9kVCDQYGORAwGAABGDxbwAjggPIYdKFvBCkNQ04dywadZ3nCc-1vX5BUBSV2GfL46LLGN9SCZ90xlOU-2RPDEJQmAiKne4ZznI4KKotEaMxJiGKY5tWOwEhnzk8t9S4nj8P4wSSOEsixMeSjqP+TFsVk7VmIzBT-GU8z5LtdTcM0wjiNI0SF0MyTjKxUsGI44MbHYptVLtQ1uMoIA" rel="noopener noreferrer"&gt;this Typescript Playground&lt;/a&gt; 🎈
&lt;/h2&gt;




&lt;h3&gt;
  
  
  Code Breakdown
&lt;/h3&gt;

&lt;p&gt;Our goal here is to make sure the developer that uses a function of type &lt;code&gt;TGetProperty&lt;/code&gt;, will have Typescript guard the arguments he gives that function.&lt;/p&gt;

&lt;p&gt;In our case, we want to make sure that every item in the &lt;code&gt;keys&lt;/code&gt; array is &lt;strong&gt;either&lt;/strong&gt; of type &lt;code&gt;STYLE_PROPERTY[]&lt;/code&gt; &lt;strong&gt;or&lt;/strong&gt; &lt;code&gt;THEME_PROPERTY[]&lt;/code&gt;.&lt;br&gt;
By defining the &lt;code&gt;type&lt;/code&gt; argument as &lt;code&gt;DATA_TYPE.STYLE&lt;/code&gt; &lt;strong&gt;or&lt;/strong&gt; &lt;code&gt;DATA_TYPE.THEME&lt;/code&gt;&lt;br&gt;
we get the type of the &lt;code&gt;keys&lt;/code&gt; argument.&lt;/p&gt;

&lt;h4&gt;
  
  
  This is a scalable solution
&lt;/h4&gt;

&lt;p&gt;If we want to add another enum like &lt;code&gt;CONTENT_PROPERTY&lt;/code&gt; for example, all we need to do is add it to &lt;code&gt;ListGetTypeMap&lt;/code&gt; and &lt;code&gt;ObjectGetTypeMap&lt;/code&gt;; and we have support for it too 🎇&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's see some examples
&lt;/h3&gt;

&lt;p&gt;Say &lt;code&gt;func1&lt;/code&gt; is a function that is of type &lt;code&gt;TGetProperty&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Bad examples ⛔
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fgb3m5qv9at32eyem7sxy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fgb3m5qv9at32eyem7sxy.png" alt="First bad example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When passing &lt;code&gt;DATA_TYPE.STYLE&lt;/code&gt; to the &lt;code&gt;type&lt;/code&gt; argument, Typescript expects the next argument to be of type &lt;code&gt;STYLE_PROPERTY&lt;/code&gt; &lt;strong&gt;only&lt;/strong&gt;,&lt;br&gt;
and the error message is pretty clear too so that's cool 🆒&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F3p2x2a88sdagzrs9c5m9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F3p2x2a88sdagzrs9c5m9.png" alt="Second bad example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Same here, passing &lt;code&gt;DATA_TYPE.THEME&lt;/code&gt; to &lt;code&gt;type&lt;/code&gt; will make Typescript reject an array with items of type &lt;code&gt;STYLE_PROPERTY&lt;/code&gt;, and &lt;strong&gt;only&lt;/strong&gt; accept items of type &lt;code&gt;THEME_PROPERTY&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Good examples ✅
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.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%2F9zv8cnu3o2paxi1qoy0h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F9zv8cnu3o2paxi1qoy0h.png" alt="Good examples"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Use Typescript to help set guards and guidelines for the next developer that will use the functions you wrote.&lt;br&gt;
This will result in fewer bugs and overall more productive coding.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>dependent</category>
    </item>
    <item>
      <title>5 Preferences Tweaks For A New Mac</title>
      <dc:creator>Daniel Bellmas</dc:creator>
      <pubDate>Sat, 22 Oct 2022 11:02:33 +0000</pubDate>
      <link>https://dev.to/danielbellmas/5-preferences-tweaks-for-a-new-mac-2f4f</link>
      <guid>https://dev.to/danielbellmas/5-preferences-tweaks-for-a-new-mac-2f4f</guid>
      <description>&lt;h2&gt;
  
  
  1. Screenshot Shortcut
&lt;/h2&gt;

&lt;p&gt;The default when taking a screenshot is to save it, but most often we want to just send it to someone right away so to make things easier, change the shortcut to:&lt;br&gt;
⌘ Cmd + ⇧ Shift + 4&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LfySuhyE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jjlhfvw7z21vo5ewksnn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LfySuhyE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jjlhfvw7z21vo5ewksnn.png" alt="Screenshot Shortcut - preferences" width="800" height="662"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Go to &lt;code&gt;System Preferences&lt;/code&gt; -&amp;gt; &lt;code&gt;Keyboard&lt;/code&gt; -&amp;gt; &lt;code&gt;Shortcuts&lt;/code&gt; tab&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  2. Speed of Mouse Cursor
&lt;/h2&gt;

&lt;p&gt;The default speed is too slow in my opinion, change it to your liking, he is mine 🙂&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AdzL1uXu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i1yus38t4owlslvgw53e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AdzL1uXu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i1yus38t4owlslvgw53e.png" alt="Speed of Mouse Cursor - preferences" width="800" height="395"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Go to &lt;code&gt;System Preferences&lt;/code&gt; -&amp;gt; &lt;code&gt;Mouse&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  3. Speed of keyboard Cursor
&lt;/h2&gt;

&lt;p&gt;The default here is also slower than what I prefer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0vaEllzf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7osf85kbw1sf7y11lchf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0vaEllzf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7osf85kbw1sf7y11lchf.png" alt="keyboard Cursor - preferences" width="800" height="668"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Go to &lt;code&gt;System Preferences&lt;/code&gt; -&amp;gt; &lt;code&gt;Keyboard&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  4. Untick the &lt;code&gt;fn&lt;/code&gt; Option
&lt;/h2&gt;

&lt;p&gt;This option will remove the need for pressing the &lt;code&gt;fn&lt;/code&gt; key with one of the &lt;code&gt;F1, F2, F3....&lt;/code&gt; keys.&lt;/p&gt;

&lt;p&gt;Most often I use the F2 key to &lt;a href="https://dev.to/danielbellmas/productivity-boost-with-cmd-ctrl-1nh8#bonus-productivity-tip-%EF%B8%8F"&gt;change variable names in &lt;code&gt;VsCode&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Unfortunately, this only works for an apple keyboard, not external ones.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kJ3HitJL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qkkaf1fnbgfpwj6v24vw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kJ3HitJL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qkkaf1fnbgfpwj6v24vw.png" alt="fn key - preferences" width="800" height="658"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Go to &lt;code&gt;System Preferences&lt;/code&gt; -&amp;gt; &lt;code&gt;Keyboard&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  5. Text Replacements
&lt;/h2&gt;

&lt;p&gt;Save time by putting your most frequently used phrases here.&lt;br&gt;
My favorite is the email one :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q_Eqtdc---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t4q1jbtupqjav0hnapda.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q_Eqtdc---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t4q1jbtupqjav0hnapda.png" alt="Text Replacements - preferences" width="800" height="661"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Go to &lt;code&gt;System Preferences&lt;/code&gt; -&amp;gt; &lt;code&gt;Keyboard&lt;/code&gt; -&amp;gt; &lt;code&gt;Text&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>productivity</category>
      <category>customize</category>
      <category>tooling</category>
      <category>ios</category>
    </item>
    <item>
      <title>Preload Fonts in Storybook</title>
      <dc:creator>Daniel Bellmas</dc:creator>
      <pubDate>Sun, 16 Oct 2022 14:10:38 +0000</pubDate>
      <link>https://dev.to/danielbellmas/preload-fonts-in-storybook-2714</link>
      <guid>https://dev.to/danielbellmas/preload-fonts-in-storybook-2714</guid>
      <description>&lt;h3&gt;
  
  
  &lt;a href="https://dev.to/danielbellmas/preload-fonts-2jh7"&gt;Click here to see how to Preload Fonts&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;To make it work in &lt;code&gt;Storybook&lt;/code&gt;, all we need to do is to utilize the &lt;code&gt;preview-head.html&lt;/code&gt; file (create it in the &lt;code&gt;.storybook&lt;/code&gt; folder) that serves the same purpose as the &lt;code&gt;react-helmet-async&lt;/code&gt; library in react - injects its content into the &lt;code&gt;head&lt;/code&gt; tag.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://storybook.js.org/docs/react/configure/story-rendering"&gt;See the story-rendering section in the docs&lt;/a&gt; for more information about how we can add code that affects all stories.&lt;/p&gt;

</description>
      <category>storybook</category>
      <category>webdev</category>
      <category>design</category>
      <category>html</category>
    </item>
    <item>
      <title>Preload Fonts</title>
      <dc:creator>Daniel Bellmas</dc:creator>
      <pubDate>Sun, 16 Oct 2022 11:42:49 +0000</pubDate>
      <link>https://dev.to/danielbellmas/preload-fonts-2jh7</link>
      <guid>https://dev.to/danielbellmas/preload-fonts-2jh7</guid>
      <description>&lt;p&gt;Usually, fonts are either downloaded from a third-party source, such as &lt;em&gt;Google Fonts&lt;/em&gt;, or from a file that is stored in the build folder.&lt;/p&gt;

&lt;p&gt;After running the build we get a static folder that houses 2 folders: &lt;em&gt;js&lt;/em&gt;, &lt;em&gt;css&lt;/em&gt;.&lt;br&gt;
If we downloaded some font files they will be inside a third folder: &lt;em&gt;media&lt;/em&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We can manually download them, or download a npm package, like &lt;code&gt;@fontsource&lt;/code&gt;, that inside it has the files.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The browser will then load those at its own pace, but that will probably cause a UI flicker of the &lt;u&gt;default browser fonts&lt;/u&gt; and then the &lt;u&gt;desired fonts&lt;/u&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For a better UI feel, we have to tell the browser to preload them.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In order to achieve that we need to add a &lt;code&gt;link&lt;/code&gt; tag that preloads the &lt;code&gt;href&lt;/code&gt; it's given:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;

&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt;
&lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"preload"&lt;/span&gt;
&lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://fonts.gstatic.com/s/poppins/v20/pxiEyp8kv8JHgFVrJJfecnFHGPc.woff2"&lt;/span&gt;
&lt;span class="na"&gt;as=&lt;/span&gt;&lt;span class="s"&gt;"font"&lt;/span&gt;
&lt;span class="na"&gt;crossOrigin=&lt;/span&gt;&lt;span class="s"&gt;"anonymous"&lt;/span&gt;
&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;


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

&lt;/div&gt;
&lt;h3&gt;
  
  
  But how do I know what to put inside the &lt;code&gt;href&lt;/code&gt;?
&lt;/h3&gt;
&lt;h4&gt;
  
  
  For that, we need to open the network tab in the dev tools, see what the browser loads, and copy it :)
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fuwduk4hmk04poygm99dp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fuwduk4hmk04poygm99dp.png" alt="Font url in the network tab in dev tools"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To locate the font request, choose the Font filter at the top.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If we are using &lt;code&gt;React&lt;/code&gt; we can add this &lt;code&gt;link&lt;/code&gt; tag to the &lt;code&gt;index.html&lt;/code&gt; (just like in &lt;code&gt;Vanilla JS&lt;/code&gt;) or inside our &lt;code&gt;App.tsx&lt;/code&gt;, but to access the &lt;code&gt;head&lt;/code&gt; tag from &lt;code&gt;App.tsx&lt;/code&gt; we'll need to use the help of the &lt;code&gt;react-helmet-async&lt;/code&gt; library.&lt;br&gt;
All it does is insert its children to the &lt;code&gt;head&lt;/code&gt; tag.&lt;br&gt;
And of course, instead of "dirting" our &lt;code&gt;App.tsx&lt;/code&gt; with more code, we can wrap it in a separate component - &lt;code&gt;&amp;lt;PreloadFonts /&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This nav bar, for example, will look like this for a split second (the gif is slowed down for a better look at the change).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fxf2kiapbt63hyiw6blzz.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fxf2kiapbt63hyiw6blzz.gif" alt="UI flicker when not preloading"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But after preloading the font we get no flicker:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fgfevmgqr1ycn98hoqr05.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fgfevmgqr1ycn98hoqr05.gif" alt="After preloading"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  The same process applies to the fonts that come from a library or font files that we downloaded, the only difference is that &lt;u&gt;the &lt;code&gt;href&lt;/code&gt; will be relative&lt;/u&gt;, like so:
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;

&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt;
&lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"preload"&lt;/span&gt;
&lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/static/media/libre-franklin-latin-400-normal.woff2"&lt;/span&gt;
&lt;span class="na"&gt;as=&lt;/span&gt;&lt;span class="s"&gt;"font"&lt;/span&gt;
&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"font/woff2"&lt;/span&gt;
&lt;span class="na"&gt;crossOrigin=&lt;/span&gt;&lt;span class="s"&gt;"anonymous"&lt;/span&gt;
&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;


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

&lt;/div&gt;




&lt;p&gt;Now my question is why not all fonts are preloaded automatically if there is an evident UI flicker?!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fs239nnq2oy8kddgcvr2p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fs239nnq2oy8kddgcvr2p.png" alt="Funny meme from friend where Joe says why god?!"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>design</category>
      <category>html</category>
      <category>react</category>
    </item>
    <item>
      <title>React Typescript Snippets</title>
      <dc:creator>Daniel Bellmas</dc:creator>
      <pubDate>Sat, 15 Oct 2022 10:09:02 +0000</pubDate>
      <link>https://dev.to/danielbellmas/react-typescript-snippets-2mlm</link>
      <guid>https://dev.to/danielbellmas/react-typescript-snippets-2mlm</guid>
      <description>&lt;p&gt;If you too are tired of typing the same code when creating a new component in react than &lt;code&gt;VS Code&lt;/code&gt; provides a cool solution: &lt;strong&gt;Code snippets&lt;/strong&gt; 🔥.&lt;/p&gt;

&lt;p&gt;Here are two snippets for Creating React components with Typescript:&lt;/p&gt;

&lt;h2&gt;
  
  
  Default Exported React Component
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.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%2F5x5kb1tk868w9sdbjs4j.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F5x5kb1tk868w9sdbjs4j.gif" alt="Default Exported React Component - snippet"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

  &lt;/span&gt;&lt;span class="nl"&gt;"Typescript default React component"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"scope"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"typescriptreact"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"prefix"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"rfcd"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"body"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"import React, { FC } from 'react'"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"interface ${TM_FILENAME_BASE}Props {"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"  $1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"const ${TM_FILENAME_BASE}: FC&amp;lt;${TM_FILENAME_BASE}Props&amp;gt; = ({ $2 }) =&amp;gt; {"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"  return ("&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"    &amp;lt;div&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"     ${3:$TM_FILENAME_BASE}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"    &amp;lt;/div&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"  )"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"export default ${TM_FILENAME_BASE};"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;h2&gt;
  
  
  Exported React Component
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fjba0rtgoqfxk52bd0zlt.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fjba0rtgoqfxk52bd0zlt.gif" alt="Exported React Component - snippet"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nl"&gt;"Typescript React component"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"scope"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"typescriptreact"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"prefix"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"rfc"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"body"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"import React, { FC } from 'react'"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"interface ${TM_FILENAME_BASE}Props {"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"  $1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"export const ${TM_FILENAME_BASE}: FC&amp;lt;${TM_FILENAME_BASE}Props&amp;gt; = ({ $2 }) =&amp;gt; {"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"  return ("&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"    &amp;lt;div&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"     ${3:$TM_FILENAME_BASE}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"    &amp;lt;/div&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"  )"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;
&lt;h3&gt;
  
  
  Flow breakdown
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Type the prefix, in this case, &lt;code&gt;rfc&lt;/code&gt; or &lt;code&gt;rfcd&lt;/code&gt;. (You can call them whatever you like 🙂).&lt;/li&gt;
&lt;li&gt;Write the interface props.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Press the tab&lt;/strong&gt; to jump to the function.&lt;/li&gt;
&lt;li&gt;Add the props you wrote in the interface. &lt;em&gt;(This feels like another step that can be optimized, take the props from the interface but I haven't yet found a solution for that)&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Press tab&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Start writing the return of the component or just leave it as is with the Component's name.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;Vs Code&lt;/code&gt; gives us variables we can use in the snippets, here I'm using the &lt;code&gt;TM_FILENAME_BASE&lt;/code&gt; variable which gives me the name of the file (without its extension).&lt;/p&gt;

&lt;p&gt;The common convention is to make the name of the file the same as the name of the component, but if that's not your case then it's possible to alter that variable, &lt;a href="https://code.visualstudio.com/docs/editor/userdefinedsnippets#_transform-examples" rel="noopener noreferrer"&gt;look here for more information&lt;/a&gt;.&lt;/p&gt;



&lt;blockquote&gt;
&lt;p&gt;To create your own snippets you'll need to go to Code &amp;gt; Preferences (User Snippets under File &amp;gt; Preferences &lt;strong&gt;on Windows&lt;/strong&gt;), and then select the language for which the snippets should appear, or the New Global Snippets file option.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;I've heard of an extension called &lt;a href="https://marketplace.visualstudio.com/items?itemName=Huuums.vscode-fast-folder-structure" rel="noopener noreferrer"&gt;Folder Template&lt;/a&gt;, which creates a folder structure that has a ready-made template inside, I haven't tried it yet but it seems like a good productivity hack, so stay tuned for another post about it in the near future 🙂.&lt;/p&gt;

</description>
      <category>react</category>
      <category>typescript</category>
      <category>vscode</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Return Type That Is Dependent On Argument's Type</title>
      <dc:creator>Daniel Bellmas</dc:creator>
      <pubDate>Mon, 10 Oct 2022 13:56:25 +0000</pubDate>
      <link>https://dev.to/danielbellmas/return-type-that-is-dependent-on-arguments-type-1o1m</link>
      <guid>https://dev.to/danielbellmas/return-type-that-is-dependent-on-arguments-type-1o1m</guid>
      <description>&lt;p&gt;In this example, the return type of a hook depends on whether the argument is passed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fig1oxgol6u7t6atni720.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fig1oxgol6u7t6atni720.png" alt="useBreakpoint hook"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So here we have a &lt;code&gt;useBreakpoint&lt;/code&gt; hook that, from the screen resolution, gives us the current breakpoint we're on; and it also allows us to &lt;strong&gt;optionally&lt;/strong&gt; pass a &lt;code&gt;breakpointMap&lt;/code&gt;, which is just an object that maps a breakpoint to some styles we want to change according to the current breakpoint (&lt;code&gt;activeBreakpoint&lt;/code&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  The Objective
&lt;/h3&gt;

&lt;p&gt;Tell Typescript to make &lt;code&gt;mappedValue&lt;/code&gt;'s type &lt;code&gt;undefined&lt;/code&gt; only if the &lt;code&gt;breakpointMap&lt;/code&gt;(the argument) &lt;strong&gt;is not passed&lt;/strong&gt;.&lt;br&gt;
If it &lt;strong&gt;is passed&lt;/strong&gt;, we want it to be defined as the value of the mapped object.&lt;/p&gt;



&lt;p&gt;&lt;a href="https://media.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%2Fsud1qi1lgx9pz25dwe7l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fsud1qi1lgx9pz25dwe7l.png" alt="The return type"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At the return we let Typescript know the hook's return type by using &lt;a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#type-assertions" rel="noopener noreferrer"&gt;type assertions&lt;/a&gt;.&lt;/p&gt;



&lt;p&gt;&lt;a href="https://media.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%2Frwcl7h52lah21sgypyvj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Frwcl7h52lah21sgypyvj.png" alt="Types"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can use the power of Generics as if they were function arguments.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;UseBreakpointsResult&lt;/code&gt; receives 2 generic types &lt;code&gt;T&lt;/code&gt; and &lt;code&gt;V&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;T&lt;/code&gt;&lt;/strong&gt; is the type of the &lt;u&gt;value mapped to each breakpoint&lt;/u&gt;, for example:
&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;breakpointMap&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;sm&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="na"&gt;md&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="na"&gt;lg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;c&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Here, &lt;code&gt;T&lt;/code&gt; will be a &lt;code&gt;string&lt;/code&gt;, because &lt;code&gt;"a"&lt;/code&gt; or &lt;code&gt;"b"&lt;/code&gt; or &lt;code&gt;"c"&lt;/code&gt; are the values there are mapped.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;V&lt;/code&gt;&lt;/strong&gt; - we pass &lt;code&gt;typeof breakpointMap&lt;/code&gt;, which can either be &lt;code&gt;undefined&lt;/code&gt; (no arguments passed) or &lt;code&gt;T&lt;/code&gt; (a map object was passed).&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  The important thing to understand here is that &lt;code&gt;mappedValue&lt;/code&gt;'s type &lt;u&gt;won't be with a union separator (&lt;code&gt;undefined | T&lt;/code&gt;)&lt;/u&gt;, it's &lt;strong&gt;either&lt;/strong&gt; &lt;code&gt;T&lt;/code&gt; &lt;strong&gt;or&lt;/strong&gt; &lt;code&gt;undefined&lt;/code&gt;.
&lt;/h4&gt;

&lt;p&gt;That is done by asking: &lt;code&gt;V extends undefined ? never : T&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If &lt;code&gt;V&lt;/code&gt; is &lt;code&gt;undefined&lt;/code&gt; then we don't want the &lt;code&gt;mappedValue&lt;/code&gt;, otherwise let &lt;code&gt;mappedValue&lt;/code&gt;'s type be &lt;code&gt;T&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  Why is it so critical to tell &lt;code&gt;Typescript&lt;/code&gt; &lt;code&gt;mappedValue&lt;/code&gt; should either be &lt;code&gt;undefined&lt;/code&gt; or &lt;code&gt;T&lt;/code&gt;?
&lt;/h3&gt;

&lt;p&gt;If we don't check the type of the argument then the type is either &lt;code&gt;T | undefined&lt;/code&gt;, which means we have to check if it's &lt;code&gt;undefined&lt;/code&gt; every time before we render our component, or add a &lt;a href="https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-0.html#non-null-assertion-operator" rel="noopener noreferrer"&gt;Non-null assertion operator&lt;/a&gt;, which  will uglify the code unnecessarily.&lt;/p&gt;
&lt;h2&gt;
  
  
  Using vs. Not Using This Method
&lt;/h2&gt;
&lt;h3&gt;
  
  
  ✅ Using
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;When the &lt;code&gt;breakpointMap&lt;/code&gt; &lt;strong&gt;is not passed&lt;/strong&gt; the type will be &lt;code&gt;undefined&lt;/code&gt;:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fxhcoibtv2vdsdcfvg49f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fxhcoibtv2vdsdcfvg49f.png" alt="breakpointMap not passed"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When the &lt;code&gt;breakpointMap&lt;/code&gt; &lt;strong&gt;is passed&lt;/strong&gt; the type will be, in this instance, &lt;code&gt;string&lt;/code&gt;:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fyeofp058rqlqzpou7u5q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fyeofp058rqlqzpou7u5q.png" alt="breakpointMap passed"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  ⛔️ Not Using
&lt;/h3&gt;

&lt;p&gt;Here we define the &lt;code&gt;mappedValue&lt;/code&gt;'s type to be &lt;code&gt;T | undefined&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Ft1ehp10p940h51lx0x2g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Ft1ehp10p940h51lx0x2g.png" alt="Not using this method"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When &lt;code&gt;mappedValue&lt;/code&gt;'s type is &lt;code&gt;T | undefined&lt;/code&gt; we'll get this error:&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  ⚡️ Even though we passed the &lt;code&gt;breakpointMap&lt;/code&gt;! ⚡️
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fxb2wxwvpx53vcp3nduaq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fxb2wxwvpx53vcp3nduaq.png" alt="T | undefined error"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h4&gt;
  
  
  Press on &lt;code&gt;Open Sandbox&lt;/code&gt; to play with the code 🎈
&lt;/h4&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;a href="https://codesandbox.io/p/sandbox/return-type-of-hook-dependent-on-arguments-type-djiebi?embed=1" rel="noopener noreferrer"&gt;
      codesandbox.io
    &lt;/a&gt;
&lt;/div&gt;





&lt;p&gt;Typescript helps us to better communicate our intentions and understand others' intentions.&lt;br&gt;
So be like this bird and go explore Typescript! 🗺 🦅&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F5i2g5yt5gkvv5tb1thug.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F5i2g5yt5gkvv5tb1thug.png" alt="Typescript process meme"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>react</category>
      <category>hooks</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
