<?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: RamaDevsign</title>
    <description>The latest articles on DEV Community by RamaDevsign (@orama254).</description>
    <link>https://dev.to/orama254</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%2F242806%2Fb3034c01-65d6-4988-a180-f751a5d26b3b.png</url>
      <title>DEV Community: RamaDevsign</title>
      <link>https://dev.to/orama254</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/orama254"/>
    <language>en</language>
    <item>
      <title>What Does "!" Symbol Mean in Typescript?</title>
      <dc:creator>RamaDevsign</dc:creator>
      <pubDate>Wed, 17 Aug 2022 13:06:05 +0000</pubDate>
      <link>https://dev.to/orama254/what-does-symbol-mean-in-typescript-22a1</link>
      <guid>https://dev.to/orama254/what-does-symbol-mean-in-typescript-22a1</guid>
      <description>&lt;p&gt;In this short guide, I will introduce you to the Definite Assignment Assertion feature in typescript and demonstrate to you an interesting use case to implement this feature.&lt;/p&gt;

&lt;h4&gt;
  
  
  Prerequisites 
&lt;/h4&gt;

&lt;p&gt;This guide assumes you have basic knowledge of &lt;a href="https://www.typescriptlang.org/" rel="noopener noreferrer"&gt;Typescript&lt;/a&gt;, you have a basic understanding of the &lt;a href="https://stripe.com/docs/api" rel="noopener noreferrer"&gt;Stripe API&lt;/a&gt;, and you have installed the &lt;a href="https://marketplace.visualstudio.com/items?itemName=mattpocock.ts-error-translator" rel="noopener noreferrer"&gt;Typescript error translator&lt;/a&gt; extension.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  The Problem
&lt;/h4&gt;

&lt;p&gt;When working with the Stripe API in one of my Next.js &amp;amp; Typescript projects, I came across an error where typescript didn't recognize my environment variable as a string. It later displayed the error message below.&lt;br&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%2Fficlszeo6qc4cs2yr3ag.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%2Fficlszeo6qc4cs2yr3ag.png" alt="environment variables returns an error in typescript environment"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  The Solution
&lt;/h4&gt;

&lt;p&gt;The solution in this case is to use the "!" symbol which is a feature in Typescript known as the definite assignment assertion. &lt;/p&gt;

&lt;p&gt;As defined in the official &lt;a href="https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#definite-assignment-assertions" rel="noopener noreferrer"&gt;Typescript Documentation&lt;/a&gt;, the definite assignment assertion feature is used to tell the compiler that the variable assigned is indeed valid for all intents and purposes, even if Typescript's analyses cannot detect so. &lt;/p&gt;

&lt;p&gt;The "!" symbol is used and is declared after an instance property and/or variable declarations.&lt;br&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%2Fqn1oxs2mc00s4mo1q2gb.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%2Fqn1oxs2mc00s4mo1q2gb.png" alt="environment variables error fixed with ! symbol (definite assignment assertion)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the definite assignment assertion, we can assert that indeed in this case we have environment variables (&lt;code&gt;process.env.STRIPE_SECRET_KEY&lt;/code&gt;) in string format and there is nothing to worry about.&lt;/p&gt;

&lt;p&gt;This workaround still leaves us with weaker type safety since any misconfiguration (in our case the environment variables) could lead to errors that cannot be caught at compile time. These errors can only be caught at runtime which beats the logic of having a strict and functional type checking system. With this in mind it's your responsibility to ensure correctness.&lt;/p&gt;

&lt;p&gt;It's also good to note that previous Typescript versions used the "!" symbol as a non-null assertion operator. You can read more about this in the &lt;a href="https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-0.html#non-null-assertion-operator" rel="noopener noreferrer"&gt;Typescript Documentation about Non-null assertion operator&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you for reading this far and happy coding!&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>tutorial</category>
      <category>react</category>
    </item>
    <item>
      <title>How to convert your JavaScript object literals to Typescript</title>
      <dc:creator>RamaDevsign</dc:creator>
      <pubDate>Thu, 14 Apr 2022 13:47:05 +0000</pubDate>
      <link>https://dev.to/orama254/how-to-convert-your-javascript-object-literals-to-typescript-mf5</link>
      <guid>https://dev.to/orama254/how-to-convert-your-javascript-object-literals-to-typescript-mf5</guid>
      <description>&lt;h3&gt;
  
  
  What is an object literal?
&lt;/h3&gt;

&lt;p&gt;A JavaScript object literal is a comma-separated list of name-value pairs encapsulated inside curly braces, kind of like a JSON structure.&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;student&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1056&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bazuu&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hello@bazumail.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;student&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// Bazuu&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;student&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// hello@bazumail.com&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;student&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// undefined (javascript)&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;The above snippet demonstrates how you can declare an object literal and access its contents. The above only applies in a JavaScript environment so if we want to convert it to typescript we will have to first change the file extension from .js to .ts&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;let&lt;/span&gt; &lt;span class="nx"&gt;student&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1056&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bazuu&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hello@bazumail.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;student&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// Bazuu&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;student&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// hello@bazumail.com&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;student&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// undefined (typescript)&lt;/span&gt;
&lt;span class="c1"&gt;// Property 'phone' does not exist on type '{ id: number; name: string; email: string; }'.ts(2339)&lt;/span&gt;
&lt;span class="nx"&gt;student1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;city&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Nairobi&lt;/span&gt;&lt;span class="dl"&gt;'&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;student&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;city&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// Property 'city' does not exist on type '{ id: number; name: string; email: string; }'.ts(2339)&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;On trying to access the object member "phone" after the conversion, typescript threw an error. I wasn't also able to add a new object member "city" either.&lt;/p&gt;

&lt;h3&gt;
  
  
  Strategies for converting to typescript.
&lt;/h3&gt;

&lt;p&gt;We can make use of two strategies when converting our object literals to typescript. The first strategy will be the any type and the second strategy will be by using an interface.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Strategy 1: using type any&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;student&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;any&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1056&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bazuu&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hello@bazumail.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;student&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// Bazuu&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;student&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// hello@bazumail.com&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;student&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// undefined &lt;/span&gt;
&lt;span class="nx"&gt;student1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;city&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Nairobi&lt;/span&gt;&lt;span class="dl"&gt;'&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;student&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;city&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// Nairobi&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;When you use type &lt;code&gt;any&lt;/code&gt;, all errors which were thrown earlier will disappear, meaning that you can access the non-existing member and you can also add new members to your object literal.&lt;/p&gt;

&lt;p&gt;Using type &lt;code&gt;any&lt;/code&gt; will temporarily "fix" the errors thrown but is an anti-pattern because is removes all the type checking which is provided by Typescript.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Strategy 2: Using an interface&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;
&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;StudentInterface&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="nl"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;phone&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;city&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;student1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;StudentInterface&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1056&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Bazuu&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hello@bazumail.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;student1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Bazuu&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;student2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;StudentInterface&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1192&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Morio&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hello@moriomail.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;student2&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="c1"&gt;// 1192&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;student3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;StudentInterface&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1345&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Zenga&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hello@zengamail.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;city&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Nairobi&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;student3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;city&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Nairobi&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;A good way to declare the member objects inside your object literals is through an interface. It makes your code look clean and you also get type safety and code documentation which improves the overall developer experience as the project grows with time.&lt;/p&gt;

&lt;p&gt;You can also include an optional object member inside the interface so that typescript doesn't throw an error incase it doesn't get the specified object member.&lt;br&gt;
You can also opt to declare your interfaces in a different file then import them in order to separate the interfaces and code logic.&lt;/p&gt;

&lt;p&gt;I hope this short write up was helpful to you and happy coding!!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to use the Javascript Set() ES6 method —100daysofleetcode epiphany</title>
      <dc:creator>RamaDevsign</dc:creator>
      <pubDate>Sat, 30 Oct 2021 16:14:50 +0000</pubDate>
      <link>https://dev.to/orama254/how-to-use-the-javascript-set-es6-method-100daysofleetcode-epiphany-52e9</link>
      <guid>https://dev.to/orama254/how-to-use-the-javascript-set-es6-method-100daysofleetcode-epiphany-52e9</guid>
      <description>&lt;p&gt;I recently started a  &lt;a href="https://twitter.com/hashtag/100daysOfLeetCode"&gt;#100DaysofLeetcode&lt;/a&gt;  challenge and came across a coding problem whose solution involved using the Javascript ES6 &lt;code&gt;Set()&lt;/code&gt; method. I dug deeper into what it was, how it works and how to use it in your day to day coding and this article will try to shed some more light into it.&lt;/p&gt;

&lt;h4&gt;
  
  
  What is the Set() method in Javascript
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;Set()&lt;/code&gt; method is used to store unique values of any type, whether primitive values or object references. You can iterate through all elements in a set and values inside a set may only occur once.&lt;/p&gt;

&lt;p&gt;Sets may look similar to Arrays but some key differences include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Elements inside an array are indexed, they are ordered and retrieved via an index reference.&lt;/li&gt;
&lt;li&gt;Sets do not support random access and reordering which are supported by arrays.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Creating a set
&lt;/h4&gt;

&lt;p&gt;When creating a set, we write &lt;code&gt;new Set()&lt;/code&gt; which creates a new empty Set.&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;blogTags&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also pass in an iterable object whose values will be added to new Set created&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;blogTags&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;HTML&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Productivity&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;h4&gt;
  
  
  Adding items to a set
&lt;/h4&gt;

&lt;p&gt;With our created Set, we can now add more items, this is done with the &lt;code&gt;add()&lt;/code&gt; method as shown below&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;blogTags&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;blogTags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Productivity&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;blogTags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;CSS&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;output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;Set(2){"Productivity","CSS"}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;trying to add a duplicate value to the newly created Set will be ignored.&lt;/p&gt;

&lt;h4&gt;
  
  
  Searching for a specific value in a set
&lt;/h4&gt;

&lt;p&gt;A set doesn't support random access but you can search for specific items inside the set with &lt;code&gt;has()&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;blogTags&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
 &lt;span class="nx"&gt;blogTags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Productivity&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="nx"&gt;blogTags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;CSS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nx"&gt;blogTags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;CSS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//true&lt;/span&gt;
&lt;span class="nx"&gt;blogTags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Javascript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Removing values from the set
&lt;/h4&gt;

&lt;p&gt;To remove a single value from the set you use &lt;code&gt;delete()&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;blogTags&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;blogTags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Productivity&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;blogTags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;CSS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;blogTags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;CSS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//true&lt;/span&gt;
&lt;span class="nx"&gt;blogTags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;CSS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;blogTags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;CSS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since sets are iterable objects, we can loop through them and also use the spread operator. Values inside a set are arranged in the order by which they were inserted inside the set created&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;blogTags&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;blogTags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Productivity&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;blogTags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;CSS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;blogTags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Devops&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;tag&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;blogTags&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="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Tags in the blog include&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;tag&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;output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;Tags in the blog include Productivity
Tags in the blog include CSS
Tags in the blog include Devops
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  When and why you would use sets
&lt;/h4&gt;

&lt;p&gt;Sets are not a replacement for arrays or other data structures but are useful for some specific situations including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When you need unique values&lt;/li&gt;
&lt;li&gt;When you don't care about random access&lt;/li&gt;
&lt;li&gt;When the order of items does not matter&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;I jumped into the  &lt;a href="https://twitter.com/hashtag/100daysOfLeetCode"&gt;#100daysofleetcode&lt;/a&gt;  challenge with a goal of being good at Data structures and Algorithms for interviews, but later realized that I'm learning alot of Javascript along the way. I've added more resources you can use to dive deep into the workings of the &lt;code&gt;Set()&lt;/code&gt; method. Hope this helped and happy Coding!!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;—  Extra resources and deep dive&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; &lt;a href="https://www.youtube.com/watch?v=4pRkrVwpLQo"&gt;Complete Guide to JS Sets: How They Work &amp;amp; When To Use Them - YouTube&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set"&gt;Set - JavaScript | MDN (mozilla.org)&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.youtube.com/watch?v=VyZaEcNPmdc"&gt;Sets in Javascript - YouTube&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>100daysofcode</category>
    </item>
    <item>
      <title>How to use npm instead of yarn with the “expo init” cli (react native tip)</title>
      <dc:creator>RamaDevsign</dc:creator>
      <pubDate>Thu, 23 Sep 2021 15:48:31 +0000</pubDate>
      <link>https://dev.to/orama254/how-to-use-npm-instead-of-yarn-with-the-expo-init-cli-react-native-tip-2h7j</link>
      <guid>https://dev.to/orama254/how-to-use-npm-instead-of-yarn-with-the-expo-init-cli-react-native-tip-2h7j</guid>
      <description>&lt;h6&gt;
  
  
  tl:dr  —  run expo init ‘project_name’ --npm
&lt;/h6&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
In this guide, I’ll show you how to use npm instead of yarn to create a new react native project while working with the expo cli.  &lt;a href="https://reactnative.dev/"&gt;React Native&lt;/a&gt;  combines the best parts of native development(Android, IOS) with React, a best-in-class JavaScript library for building user interfaces.  &lt;a href="https://expo.dev/"&gt;Expo&lt;/a&gt;  on the other hand makes this process super easy.&lt;/p&gt;
&lt;h4&gt;
  
  
  Prerequisites
&lt;/h4&gt;

&lt;p&gt;This guide assumes that you have already installed the expo cli globally. You can find a comprehensive guide on how to set that up on the  &lt;a href="https://docs.expo.dev/get-started/installation/"&gt;official expo documentation&lt;/a&gt; &lt;/p&gt;
&lt;h4&gt;
  
  
  The Problem
&lt;/h4&gt;

&lt;p&gt;You might have at one point installed yarn on your machine to follow along with a coding tutorial or as a requirement on a past project you were working on. You now have both yarn and npm installed on your machine and you don't want to uninstall either of them(for whatever technical 'it depends' reason). By default expo cli falls back to yarn when it is available but due to preference you want to use npm.&lt;/p&gt;
&lt;h4&gt;
  
  
  The Solution
&lt;/h4&gt;

&lt;p&gt;The solution in this case is to use the &lt;code&gt;--npm&lt;/code&gt; flag when initializing a new expo react native project. The cli hints at what you should use but doesn't explicitly describe where it should be used. This is done by typing &lt;code&gt;expo init project-name&lt;/code&gt; with the &lt;code&gt;--npm&lt;/code&gt; flag.&lt;/p&gt;

&lt;p&gt;e.g&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;expo init unicornfinder --npm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the &lt;code&gt;expo init 'project-name' --npm&lt;/code&gt; statement, you can now initialize your application with npm as its default package manager. Remember that you will have to run the &lt;code&gt;expo init&lt;/code&gt; command with the &lt;code&gt;--npm&lt;/code&gt; flag everytime you want a new project to use npm as your preferred package manager.&lt;/p&gt;

&lt;p&gt;Thanks for reading and Happy coding!!&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to use Environment Variables in Vite(React Template Example)</title>
      <dc:creator>RamaDevsign</dc:creator>
      <pubDate>Fri, 27 Aug 2021 16:33:12 +0000</pubDate>
      <link>https://dev.to/orama254/how-to-use-environment-variables-in-vite-react-template-example-34ff</link>
      <guid>https://dev.to/orama254/how-to-use-environment-variables-in-vite-react-template-example-34ff</guid>
      <description>&lt;p&gt;&lt;em&gt;tl:dr — Use &lt;code&gt;import.meta.env&lt;/code&gt; instead of &lt;code&gt;process.env&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://vitejs.dev/" rel="noopener noreferrer"&gt;Vite&lt;/a&gt;  is a handy build tool when you want to spin up a quick react application. In this guide, I will walk you through how to use environment variables inside a react application template created though vite.&lt;/p&gt;

&lt;h4&gt;
  
  
  Prerequisites:
&lt;/h4&gt;

&lt;p&gt;This guide assumes that you know some basics of  &lt;a href="https://vitejs.dev/guide/#scaffolding-your-first-vite-project" rel="noopener noreferrer"&gt;scaffolding a vite application template&lt;/a&gt;  and also the workings of  &lt;a href="https://robertcooper.me/post/front-end-javascript-environment-variables" rel="noopener noreferrer"&gt;environment variables&lt;/a&gt; . A brief disclaimer, environment variables only store secrets during the development phase of your project. Secret or sensitive keys will be visible after a production build so be careful not to expose sensitive keys at build time.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Problem:
&lt;/h4&gt;

&lt;p&gt;Sometime back when doing a live code presentation, I wanted to use some keys from a database that was to initialize a connection to the database. The best approach would be to write all the keys inside a &lt;code&gt;.env&lt;/code&gt; file and create a connection that makes a reference to the values inside this file. Normally when creating and using environment variables, you write the JavaScript statement &lt;code&gt;process.env.SOME_VALUE&lt;/code&gt; or &lt;code&gt;process.env.REACT_APP_SOME_VALUE&lt;/code&gt; but in this instance, the react application stopped rendering information on the screen. The console error read "process is not defined". Even after installing the npm package dotenv, the error still persisted.&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%2Fjpzcn8nuua6ql98lb2qa.jpg" 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%2Fjpzcn8nuua6ql98lb2qa.jpg" alt="process_not_defined.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  The Solution:
&lt;/h4&gt;

&lt;p&gt;The solution is actually inside the  &lt;a href="https://vitejs.dev/guide/env-and-mode.html" rel="noopener noreferrer"&gt;official vite documentation.&lt;/a&gt;  Instead of using &lt;code&gt;process.env.SOME_VALUE&lt;/code&gt; or &lt;code&gt;process.env.REACT_APP_SOME_VALUE&lt;/code&gt; which is common with other projects, inside vite we use &lt;code&gt;import.meta.env.SOME_VALUE&lt;/code&gt;. When you want to expose some info inside the frontend you will have to append the statement with VITE i.e. &lt;code&gt;import.meta.env.VITE_SOME_VALUE&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;With the &lt;code&gt;import.meta.env.VITE_SOME_VALUE&lt;/code&gt; statement, we can now use environment variables inside a react application initialized inside of vite. Thank you for reading this brief writeup and hope this comes in handy when working with react inside vite.&lt;/p&gt;

&lt;p&gt;Happy Coding!&lt;/p&gt;

</description>
      <category>react</category>
      <category>vite</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How To Use React Router To Improve The UX Of Your React Application</title>
      <dc:creator>RamaDevsign</dc:creator>
      <pubDate>Thu, 24 Jun 2021 14:43:27 +0000</pubDate>
      <link>https://dev.to/orama254/how-to-use-react-router-to-improve-the-ux-of-your-react-application-380k</link>
      <guid>https://dev.to/orama254/how-to-use-react-router-to-improve-the-ux-of-your-react-application-380k</guid>
      <description>&lt;p&gt;In this guide, you will create a custom 404 page and use react router to navigate to our custom 404 page whenever a user goes to the wrong page. We will cover a brief introduction to the essentials when working with react router to manage page routing in your react application.&lt;/p&gt;

&lt;p&gt;What you will need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React Router &lt;a href="https://reactrouter.com/web/guides/quick-start/installation" rel="noopener noreferrer"&gt;(installation link here)&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Your React application&lt;/li&gt;
&lt;li&gt;A custom 404 page&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;React Router essentials:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;React Router&lt;/em&gt;&lt;/strong&gt; is a standard library for routing in React. It enables the navigation among views of various components in a React Application, allows changing the browser URL, and keeps the UI in sync with the URL  &lt;a href="https://www.geeksforgeeks.org/reactjs-router/" rel="noopener noreferrer"&gt;&lt;em&gt;source&lt;/em&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The main components to consider in our particular case include:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;BrowserRouter&lt;/strong&gt;: a router implementation that uses the HTML5 history API(pushState, replaceState and the popstate event) to keep your UI in sync with the URL. It is the parent component that is used to store all of the other components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Route&lt;/strong&gt;: Its most basic responsibility is to render some UI when its path matches the current URL.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Switch&lt;/strong&gt;: Switch component is used to render only the first route that matches the location rather than rendering all matching routes. (We will use it in our guide to render our custom 404).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link&lt;/strong&gt;: The Link component is used to create links to multiple routes and to implement navigation within the app.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;The setup&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First we have to create a new React application by either using the &lt;code&gt;create-react-app&lt;/code&gt; command or use an environment like  &lt;a href="https://codesandbox.io/" rel="noopener noreferrer"&gt;codesandbox&lt;/a&gt;  or  &lt;a href="https://codepen.io/" rel="noopener noreferrer"&gt;codepen&lt;/a&gt;  with a React template.&lt;/p&gt;

&lt;p&gt;Install react router by running the command &lt;code&gt;npm install react-router-dom&lt;/code&gt; or add it as a dependency on &lt;a href="https://codesandbox.io/" rel="noopener noreferrer"&gt;codesandbox&lt;/a&gt; or &lt;a href="https://codepen.io/" rel="noopener noreferrer"&gt;codepen.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The folder structure right now has a pages directory inside the src folder with all the pages that are necessary for this guide. We have four pages: home, about, dashboard, help and our custom 404 page. We also have a components folder with a navigation component.&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%2F6s7ydraj44eq52u8dxzf.jpg" 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%2F6s7ydraj44eq52u8dxzf.jpg" alt="file-structure-custom-404.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Inside our App.js file we import all the necessary modules from react router&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;BrowserRouter&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;Router&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-router-dom&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;We then import our specific pages and components&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="c1"&gt;//pages&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Home&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./pages/Home&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;About&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./pages/About&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Help&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./pages/Help&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Dashboard&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./pages/Dashboard&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;//components&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Nav&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./Components/Nav&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;After everything is imported we setup our application to use the functionalities provided by react router. We wrap everything inside our Router component then import our Nav component to be rendered.&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="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Router&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;Nav&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;hr&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;Router&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;After that we setup our page routing with the various route components that will navigate us to our desired pages&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="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Router&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;Nav&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;hr&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;Route&lt;/span&gt; &lt;span class="na"&gt;exact&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&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;Home&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;Route&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;Route&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/about"&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;About&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;Route&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;Route&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/help"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Help&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;Route&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;Route&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/dashboard"&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;Dashboard&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;Route&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;Router&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;Our App.js file will look like this when everything is setup correctly&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="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./styles.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;BrowserRouter&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;Router&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-router-dom&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;//pages&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Home&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./pages/Home&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;About&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./pages/About&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Help&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./pages/Help&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Dashboard&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./pages/Dashboard&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;//components&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Nav&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./Components/Nav&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Router&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;Nav&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;hr&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;Route&lt;/span&gt; &lt;span class="na"&gt;exact&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&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;Home&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;Route&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;Route&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/about"&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;About&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;Route&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;Route&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/help"&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;Help&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;Route&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;Route&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/dashboard"&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;Dashboard&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;Route&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;Router&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;&lt;iframe src="https://codesandbox.io/embed/3ndk8"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Project scenario:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's say we had a onetime bonus boost inside our fintech startup where we gifted every new user with double their initial investment. This promotion only ran for one evening and after it ended we decided as the dev team to remove that specific promotion page. &lt;/p&gt;

&lt;p&gt;Everyone that came to the page afterwards only saw a blank page which is bad user experience. How can we solve this?&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;The solution, a custom 404 page:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A custom 404 page would be the ideal solution to navigate users to our desired page, in this case the Home page.&lt;br&gt;
For this special case we will be using the &lt;code&gt;&amp;lt;Switch&amp;gt;&lt;/code&gt; component that is provided within react router. &lt;/p&gt;

&lt;p&gt;As previously discussed, we use the switch component to render only the first route that matches the specified location. With this in mind we will use the switch component to render out the first exact path that matches our desired page. &lt;/p&gt;

&lt;p&gt;We will also be adding a special route and passing it the &lt;code&gt;"*"&lt;/code&gt; prop in order to render every time a path does not match. Inside this route component we will add our custom 404 page that will be rendered every time someone enters the wrong page on our app.&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="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Router&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;Nav&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;hr&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;Switch&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;Route&lt;/span&gt; &lt;span class="na"&gt;exact&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&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;Home&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;Route&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;Route&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/about"&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;About&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;Route&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;Route&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/help"&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;Help&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;Route&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;Route&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/dashboard"&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;Dashboard&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;Route&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;Route&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&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;NotFound&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;Route&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;Switch&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;Router&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;With that we have now improved the overall User Experience in our application. When we go to any page that is not in our application it returns a custom error page and guides us to the home page.&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%2Fmt3gcv7va9mg8q8vd23x.jpg" 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%2Fmt3gcv7va9mg8q8vd23x.jpg" alt="Error-page-and-redirect-option.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/mffo2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;You can find the code to this guide  &lt;a href="https://codesandbox.io/s/improved-ux-with-router-switch-added-mffo2?file=/src/App.js:343-817" rel="noopener noreferrer"&gt;Here&lt;/a&gt; .&lt;/p&gt;

&lt;p&gt;Thank you for reaching this far and happy coding!!!&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to fix the NextJS HMR(hot reload) not working error on WSL2</title>
      <dc:creator>RamaDevsign</dc:creator>
      <pubDate>Thu, 20 May 2021 15:45:03 +0000</pubDate>
      <link>https://dev.to/orama254/how-to-fix-the-nextjs-hmr-hot-reload-not-working-error-on-wsl2-51c</link>
      <guid>https://dev.to/orama254/how-to-fix-the-nextjs-hmr-hot-reload-not-working-error-on-wsl2-51c</guid>
      <description>&lt;p&gt;&lt;em&gt;tl:dr - Transfer your workspace files from the windows environment to the Linux environment&lt;/em&gt;&lt;br&gt;
&lt;br&gt;&lt;br&gt;
While working on your NextJS application inside WSL2, you may have noticed that your saved changes do not immediately reflect on your application. This means that you will have to go through the tedious process of constantly restarting your local development server so that you can see your changes reflected.&lt;/p&gt;

&lt;p&gt;Fear not, I come forth with a potential fix for this. The results tend to vary so don't hesitate to leave a comment with your particular scenario so that we can fix it.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;The Problem…&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When working on NextJS applications inside WSL2, there seems to be an issue with  &lt;a href="https://webpack.js.org/concepts/hot-module-replacement/" rel="noopener noreferrer"&gt;HMR (Hot Reload)&lt;/a&gt;  not detecting changes to your code on save. This results in constantly refreshing the server so that you can view your changes.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;The Solution (The fix that worked for me)…&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After upgrading to WSL2 we are constantly advised to move our workspace from the Windows environment to the Linux environment for performance purposes.&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%2F5yfzisnfchmjf630j4dq.jpg" 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%2F5yfzisnfchmjf630j4dq.jpg" alt="use_linux_environment_instead_of_windows_environment_for_performance.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Our first step will be to copy our current workspace inside windows to our Linux workspace inside WSL2.&lt;/p&gt;

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

cp –R &amp;lt;source_folder&amp;gt; &amp;lt;destination_folder&amp;gt;

e.g
cp -R /mnt/c/&amp;lt;your_folder_name&amp;gt; /home


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

&lt;/div&gt;

&lt;p&gt;Now that we are inside the Linux environment, we can start doing some house keeping by first deleting the node_modules folder and the package-lock.json file.&lt;/p&gt;

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

rm –r node_modules package-lock.json


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

&lt;/div&gt;

&lt;p&gt;After that you can run the npm install command to install all the necessary dependencies for the project.&lt;/p&gt;

&lt;p&gt;After all the dependencies have been installed you can launch your text editor and start working inside your new environment without any errors.&lt;/p&gt;

&lt;p&gt;Congratulations on fixing this error with me!!&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Additional Info…&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Incase you get some error related to write access when trying to edit files inside your folder you can use the &lt;em&gt;chown&lt;/em&gt; command in Linux to give ownership access to your specific folder.&lt;/p&gt;

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

sudo chown –R &amp;lt;username&amp;gt; &amp;lt;folder_name&amp;gt;


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

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;
With that problem solved you can now continue with your development and enjoy the many benefits of NextJS and a Linux environment inside WSL2.&lt;br&gt;
 &lt;br&gt;
If this guide was helpful, don't hesitate to drop a like and a comment. Happy coding.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>wsl</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Open source contribution for Experience and Confidence</title>
      <dc:creator>RamaDevsign</dc:creator>
      <pubDate>Thu, 06 May 2021 13:34:13 +0000</pubDate>
      <link>https://dev.to/orama254/open-source-contribution-for-experience-and-confidence-3bml</link>
      <guid>https://dev.to/orama254/open-source-contribution-for-experience-and-confidence-3bml</guid>
      <description>&lt;p&gt;During my escapades in open source contribution, I happened to come across a unique situation which required me to learn something new in order to make my open source contribution a success. For a long time, I used to think that some git commands were reserved for a certain seniority or experience level, but this situation changed my perspective on how I approached it.&lt;/p&gt;

&lt;p&gt;Contributing to open source has a lot of advantages among them being that it helps in sharpening tech skills, both reading code and writing code. There are a lot more advantages to go through but today I wanted to present to you two ways in which open source contribution can help you out in your software development career.&lt;/p&gt;

&lt;h3&gt;
  
  
  Experience
&lt;/h3&gt;

&lt;p&gt;Contributing to open source can increase your experience. There is a lot that you can work on in open source projects that will help you out in your software engineering career. &lt;/p&gt;

&lt;p&gt;One such experience moment happened to me during my open source escapades as described earlier. I had made a pull request that was not passing the markdown linting tests that were setup by the project. After reading through my code I realized that some changes were being made by local markdown linter that were not in line with the guidelines set by the project I was contributing to. Since I knew that this would be resolved by a git command, I started doing my research and found out that this could indeed be resolved by git. The command that I found was &lt;strong&gt;&lt;em&gt;git rebase&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Had I never stumbled upon this unique obstacle, I would have probably never learnt about git rebase. There is so much a tutorial can teach you, but if you want to go an extra mile in your career, I would suggest you take up open source contribution. By taking up open source contribution you also get to solve the famous paradox that &lt;strong&gt;you need a job to get experience but you need experience to get a job…&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Confidence
&lt;/h3&gt;

&lt;p&gt;Confidence is a huge necessity especially if you are starting out as a developer. With confidence on your side you get to navigate the dreaded imposter syndrome that is prevalent among us developers, a feeling that does not discriminate on experience level, whether junior or senior. &lt;/p&gt;

&lt;p&gt;You get a taste of confidence when you get some insightful feedback on your code contribution during a code review session. You get a taste of confidence when the project maintainer leaves a &lt;strong&gt;LGTM(Looks Good to Me)&lt;/strong&gt; comment on your code before merging it to the code base. This build up of confidence will ultimately motivate you to even start your own open source projects which will also pass on these two advantages to other developers starting out in open source contribution.&lt;/p&gt;




&lt;p&gt;With experience and confidence you can achieve a lot in the software engineering field. I wrote this article to highlight these two advantages among many that you can find when you actively contribute to open source. If you need some help getting started or navigating the open source field, I have a list of recommendations at the end of this article that will surely get you started. If you have additional individuals or places that can be of help please feel free to comment down below and I will surely add them to this list. Until next time folks, happy coding!!!&lt;/p&gt;

&lt;p&gt; - - &lt;em&gt;My Recommended list (still being added)&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; &lt;a href="https://twitter.com/kentcdodds"&gt;Kent C. Dodds&lt;/a&gt;  &lt;/li&gt;
&lt;li&gt; &lt;a href="https://twitter.com/indigitalcolor"&gt;Monica Powell&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a href="https://twitter.com/bdougieYO"&gt;Brian Douglas&lt;/a&gt;  (Search Opensauced)&lt;/li&gt;
&lt;li&gt; &lt;a href="https://twitter.com/eddiejaoude"&gt;Eddie Jaoude&lt;/a&gt;  (Search EddieHub)&lt;/li&gt;
&lt;li&gt; &lt;a href="https://twitter.com/Samson_Goddy"&gt;Samson Goddy&lt;/a&gt;  (Search OSCA)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>opensource</category>
    </item>
    <item>
      <title>A Cool Way to Create Multiple Files for your Project in WSL/WSL2</title>
      <dc:creator>RamaDevsign</dc:creator>
      <pubDate>Thu, 01 Apr 2021 08:40:36 +0000</pubDate>
      <link>https://dev.to/orama254/a-cool-way-to-create-multiple-files-for-your-project-in-wsl-wsl2-32m0</link>
      <guid>https://dev.to/orama254/a-cool-way-to-create-multiple-files-for-your-project-in-wsl-wsl2-32m0</guid>
      <description>&lt;p&gt;For a long time now, Linux users seemed to have the upper hand when it comes to software development(with solid reasons to back them). But with the introduction of the now popular  &lt;a href="https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux"&gt;WSL (Windows Subsystem for Linux)&lt;/a&gt; , us windows folk have a reason to smile in regards to software development.&lt;/p&gt;

&lt;p&gt;Today I'm not going to dive so much into the advantages of using Linux in software development, I want to share an interesting and cool way to create multiple files inside your Linux environment with the &lt;em&gt;touch&lt;/em&gt; command.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Touch command&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;touch&lt;/em&gt; command is a standard command used in Linux based operating systems and it is used to create a file without any content &lt;a href="https://www.geeksforgeeks.org/touch-command-in-linux-with-examples/****"&gt;¹&lt;/a&gt; .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uJHhX21J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/21qmz7zhkbnudxziste5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uJHhX21J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/21qmz7zhkbnudxziste5.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
The above code results in the creation of an empty index.ts file&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1QWodjyD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/11nx7vo5u1tpw3yuourz.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1QWodjyD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/11nx7vo5u1tpw3yuourz.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating Multiple files&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The same touch command can be used to create multiple files inside your project folder&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2yFuEEQn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5obam0hq38w1qzoqqlst.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2yFuEEQn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5obam0hq38w1qzoqqlst.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code will result in the creation of an empty db.js file, an empty users.tsx file and an empty auth.ts file inside your current folder.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ENbvBe9b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l0bx960wx6g1k759awje.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ENbvBe9b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l0bx960wx6g1k759awje.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Leveling up inside the Linux terminal Matrix
&lt;/h3&gt;

&lt;p&gt;If you have ever run into a task that requires the creation of multiple files of the same extension, it reaches a point where it gets too repetitive and that's what happened to me a while back when creating files in a previous project. The file extension was .graphql and creating 10 files with such a long extension was getting repetitive and boring. As a developer I knew that there was a better and easier way to do it.&lt;/p&gt;

&lt;p&gt;Introducing the brace expansion command. This is a handy bash feature that allows you to create long lists of arbitrary string combinations. More info on this can be found on  &lt;a href="https://wiki.bash-hackers.org/syntax/expansion/brace"&gt;this Bash Hackers Wiki article&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VT3hZemK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9qo6fsotlvv16666452g.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VT3hZemK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9qo6fsotlvv16666452g.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
The above code will result in the creation of 10 LOG files serially numbered and prefixed with the acc name&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2F97FLaY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ub566a6x3ksj5iwtzbml.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2F97FLaY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ub566a6x3ksj5iwtzbml.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Now in my particular scenario, I wanted an easier way to create 10 files with the .graphql extension. My final resolve was to use the brace expansion command and type out all the file names in one instance then assign the files with the .graphql extension as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oYwssCA4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ivrmfuxl9rhmuig5nik.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oYwssCA4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ivrmfuxl9rhmuig5nik.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
The above code resulted in my expected result of 10 files with a .graphql extension&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uA74ca9J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rzchvz3n97sv03llx61i.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uA74ca9J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rzchvz3n97sv03llx61i.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
This worked to my satisfaction and was a deserved win from my google research session. All the tabs that were open during the research can now be closed&lt;/p&gt;




&lt;p&gt;In conclusion, there are a lot of tasks that can be achieved with the brace expansion command that I have not touched on and that are efficient and effective in your day to day coding activities. &lt;/p&gt;

&lt;p&gt;The article on the  &lt;a href="https://wiki.bash-hackers.org/syntax/expansion/brace"&gt;Brace Expansion command&lt;/a&gt;  dives deep into the many scenarios that might come in handy when using it in your tasks. I highly recommend that you have a look at it. &lt;/p&gt;

&lt;p&gt;Thank you for reaching the end and kindly leave a like or a heart if you found this article insightful. What are you planning to do with your new found Linux super power?&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The React Developer Community Kenya - 6 Month Update</title>
      <dc:creator>RamaDevsign</dc:creator>
      <pubDate>Thu, 25 Mar 2021 06:38:11 +0000</pubDate>
      <link>https://dev.to/orama254/the-react-developer-community-kenya-6-month-update-3c6a</link>
      <guid>https://dev.to/orama254/the-react-developer-community-kenya-6-month-update-3c6a</guid>
      <description>&lt;p&gt;During the events of 2020(The Pandemic), a brilliant idea crossed my mind. I was learning react hooks with all the fun and cool ways of using functional components at the time and I wanted to interact with other developers who were also using react in my country. I had seen the success of the many developer groups in Kenya and wanted to replicate this as well.&lt;/p&gt;

&lt;p&gt;The first step was to look for any developer community available that was heavily biased towards react, since there were well performing developer groups on angular and vue. Now don't get me wrong, I don't hate working with angular or vue, I wanted to learn and share my acquired knowledge and skill in react to fellow developers that were also in their various learning paths related to react. It was great that internationally there was a vibrant community that revolved around the react library and with this, I saw a gap that needed to be filled in our local developer community.&lt;/p&gt;




&lt;p&gt;After a lot of research and consultations, I decided to start the react developer community Kenya. It was not easy. First I was fairly new to the "leading a group" thing. I knew what I wanted in a developer community but I wasn't quite sure if what I had in mind would also be ideal for everybody else in the group. We are still in the early stages of growth and I am grateful that The tech community in the 254 embraced it.&lt;/p&gt;




&lt;p&gt;The six months had a fair share of its ups and downs. Let me first start with the ups.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We are currently at 50 group members on our Telegram channel(as at 10th March 2021), though not very active but this will change as the numbers continue to grow&lt;/li&gt;
&lt;li&gt;We currently have a GitHub organization, Twitter handle, YouTube channel which is part of the strategy to onboard new members into our yet to be vibrant community.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For some minor downs(lessons) that I know will be fixed as we progress:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The telegram platform is filled with a lot of spam from so called "crypto investors" who are constantly raiding the channels to promote their platforms. This I have found out can be fixed by introducing moderation via the famous telegram bots. There is one that we are currently using and its premium features were quite good, unfortunately the trial period ended and we switched back to the free version. The subscription is not much so I'm sending this out to anyone reading this and is willing to help out with expanding the growth of the react community in Kenya&lt;/li&gt;
&lt;li&gt;We currently don't have a meetup page as a community. This is also due to financial constraints but as we progress I am sure there will be a solution for this, also sending this out if there is someone who is willing to help.
Bootstrapping anything in the beginning with little to no financial input can be an uphill task. But I am certain there will be a way out.&lt;/li&gt;
&lt;li&gt;Bootstrapping anything in the beginning with little to no financial input can be an uphill task. But I am certain there will be a way out.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;I am very optimistic about growing a community that competes with the global demand for frontend and fullstack developers. The react ecosystem is growing globally and I wouldn't want my country to be left out in terms of this valuable skill. Since it is an open community I want to be as clear and transparent as I possibly can so that anybody who also wants to start a developer community and sees an opportunity can go ahead and start one. &lt;/p&gt;

&lt;p&gt;I know the beginnings are always the hardest but I also know that consistency compounds with time. I will be happy to review this article as we mark one year as a developer community. Kindly reach out if you want to join the community via our email address &lt;strong&gt;reactdevske{at}gmail{dot}com&lt;/strong&gt; . &lt;em&gt;(we are trying to minimize spam from email and telegram web scrapers).&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devjournal</category>
      <category>codenewbie</category>
      <category>react</category>
    </item>
  </channel>
</rss>
