<?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: Samuel Lucas</title>
    <description>The latest articles on DEV Community by Samuel Lucas (@sam_lukaa).</description>
    <link>https://dev.to/sam_lukaa</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%2F109204%2F7e976931-cd2d-435d-9360-1efd4504d798.jpg</url>
      <title>DEV Community: Samuel Lucas</title>
      <link>https://dev.to/sam_lukaa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sam_lukaa"/>
    <language>en</language>
    <item>
      <title>Automatically generating files in your React/Next Js app</title>
      <dc:creator>Samuel Lucas</dc:creator>
      <pubDate>Fri, 22 Jul 2022 23:50:00 +0000</pubDate>
      <link>https://dev.to/sam_lukaa/automatically-generating-files-in-your-reactnext-js-app-4e0g</link>
      <guid>https://dev.to/sam_lukaa/automatically-generating-files-in-your-reactnext-js-app-4e0g</guid>
      <description>&lt;p&gt;Creating files is actually one of the first steps in building a successful application, but having to create files that follow specific pattern, multiple times plus manually can become so tiring.😪&lt;/p&gt;

&lt;p&gt;Hello my dear reader, how are you today?&lt;br&gt;
Today, I'll be teaching you how to automate file creation in react/next js using what is called &lt;a href="https://www.npmjs.com/package/plop"&gt;Plop&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;What is Plop? It is a Micro-generator framework that makes it easy for an entire team to create files with a level of uniformity.&lt;/p&gt;

&lt;p&gt;At least, that's what they say it is, and that's really what it is.&lt;/p&gt;

&lt;p&gt;To the main point, how do I use this awesome package?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install it from &lt;a href="https://www.npmjs.com/package/plop"&gt;npm&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;After successful installation, you'll need to create two things&lt;/li&gt;
&lt;li&gt;a file called &lt;strong&gt;plopFile.js&lt;/strong&gt;: This is where you get to define the actions you want to carry out.&lt;/li&gt;
&lt;li&gt;a folder called &lt;strong&gt;templates&lt;/strong&gt;: within this folder, you'll create a file that the &lt;strong&gt;plopFile&lt;/strong&gt; will replicate, i.e the way you want the generated file to look like.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's talk about the &lt;strong&gt;templates&lt;/strong&gt; folder. So, in this post I'll assume we are working within the components folder to create components(such as Button, Text, Inputs...) for our app.&lt;/p&gt;

&lt;p&gt;The goal is to create the first component, &lt;strong&gt;Button&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Back to the templates folder, create another folder called &lt;strong&gt;components&lt;/strong&gt;, and within this folder, create a file called &lt;strong&gt;component.hbs&lt;/strong&gt;. Plop works with hbs files, that's why we have it that way.&lt;/p&gt;

&lt;p&gt;Within the &lt;strong&gt;component.hbs&lt;/strong&gt; file, let's create a skeleton of what we want each of our components to look like, 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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&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="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{{&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{{&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&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;Every component file we create will follow this format.&lt;br&gt;
You may be wondering, where the heck is &lt;code&gt;{{name}}&lt;/code&gt; coming form, Lucas? 🧐&lt;/p&gt;

&lt;p&gt;Let's see. &lt;code&gt;{{name}}&lt;/code&gt; is the name we give our component when creating it, such as Button, Text..., but then where are we setting it?&lt;/p&gt;

&lt;p&gt;That's where the &lt;strong&gt;plopFile.js&lt;/strong&gt; comes in. Let's head there now.&lt;/p&gt;

&lt;p&gt;I assume you're now within the file.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A plopfile starts its life as a node module that creates a function which accepts the plop object as its first parameter.&lt;/li&gt;
&lt;li&gt;The plop object exposes the plop API object which contains the &lt;code&gt;setGenerator(name, config)&lt;/code&gt; function. This is the function that you use to (wait for it) create a generator for this plopfile. When plop is run from the terminal in this directory (or any sub-directory), a list of these generators will be displayed. In our case, let's change the name to components, since we'll be working with components files.&lt;/li&gt;
&lt;li&gt;The config is where the &lt;code&gt;description&lt;/code&gt;, &lt;code&gt;prompts&lt;/code&gt; and &lt;code&gt;actions&lt;/code&gt; go. What are they?🤔
&lt;strong&gt;description&lt;/strong&gt;: a simple description of what this generator does
&lt;strong&gt;prompts&lt;/strong&gt;: a custom user interaction function for command prompt, where you ask questions such as what component you want to create.
&lt;strong&gt;actions&lt;/strong&gt;: as its name implies, it's the actions folder where you define in which folder you want the component created, the format to follow(templates/components/component) and other interesting things.&lt;/li&gt;
&lt;li&gt;finally you export the function created.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's see it in action.&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;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;plop&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;plop&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setGenerator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;components&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="na"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;A component generator for the app&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;prompts&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="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;input&lt;/span&gt;&lt;span class="dl"&gt;'&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;name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Enter component name&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;span class="na"&gt;actions&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="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;add&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;components/{{pascalCase name}}/{{pascalCase name}}.jsx&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;templateFile&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;templates/components/component.hbs&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;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Within the &lt;code&gt;prompts&lt;/code&gt;, you'll notice we are setting the value of name to name, and that is what we got the &lt;code&gt;name&lt;/code&gt; within the &lt;code&gt;templates/components/component&lt;/code&gt; from. It could be anything, could be &lt;code&gt;name: something&lt;/code&gt; or &lt;code&gt;name: another_thing&lt;/code&gt;, just about anything.&lt;/p&gt;

&lt;p&gt;Within the actions, there are various &lt;code&gt;type&lt;/code&gt; of actions that could be carried out such as append, modify, addMany..., but we'll be using &lt;code&gt;add&lt;/code&gt; today for the purpose of this post, to add a file to a folder.&lt;/p&gt;

&lt;p&gt;The path describes what path we want the file created. You'll also notice that we have this line &lt;code&gt;{{pascalCase name}}&lt;/code&gt;, basically we have various case modifiers such as &lt;code&gt;camelCase&lt;/code&gt;, &lt;code&gt;pascalCase&lt;/code&gt;, &lt;code&gt;lowerCase&lt;/code&gt; among others so we are basically telling &lt;code&gt;plop&lt;/code&gt; to use the &lt;code&gt;pascalCase&lt;/code&gt; for the file we are creating, and the name is gotten from &lt;code&gt;name: name&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;templateFile&lt;/code&gt; is where we navigate to the format which we want our file to be created.&lt;/p&gt;

&lt;p&gt;To run what we just created, simlpy run&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;yarn&lt;/span&gt; &lt;span class="nx"&gt;run&lt;/span&gt; &lt;span class="nx"&gt;plop&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in your terminal.&lt;/p&gt;

&lt;p&gt;Works like magic 🧞.&lt;/p&gt;

&lt;p&gt;Congratulations, you have completed the mission.&lt;/p&gt;

&lt;p&gt;Thanks for taking your time to read through this. &lt;/p&gt;

&lt;p&gt;Let me know in the comment section below if you found this useful or if you knew about this before now or how productive you think this will make you be.&lt;/p&gt;

&lt;p&gt;Links below to useful resources:&lt;br&gt;
&lt;a href="https://plopjs.com/documentation/#getting-started"&gt;Plop documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=NKW65IVwm6k"&gt;Youtube video support&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In the next post, I'll be showing you advanced features of Plop such as a case where you can append to a file. &lt;/p&gt;

&lt;p&gt;Bye for now 👣&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>A cool trick to get unique items in an array in JavaScript</title>
      <dc:creator>Samuel Lucas</dc:creator>
      <pubDate>Thu, 10 Feb 2022 14:16:52 +0000</pubDate>
      <link>https://dev.to/sam_lukaa/a-cool-trick-to-get-unique-items-in-an-array-in-javascript-5c1c</link>
      <guid>https://dev.to/sam_lukaa/a-cool-trick-to-get-unique-items-in-an-array-in-javascript-5c1c</guid>
      <description>&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;array&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;uniqueArray&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&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;array&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;uniqueArray&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Result: [1, 2, 3, 5]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To learn more about arrays in JavaScript, visit &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array"&gt;MDN&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Cashing out from web development - React</title>
      <dc:creator>Samuel Lucas</dc:creator>
      <pubDate>Mon, 03 Jan 2022 19:52:32 +0000</pubDate>
      <link>https://dev.to/sam_lukaa/cashing-out-from-web-development-react-4gpo</link>
      <guid>https://dev.to/sam_lukaa/cashing-out-from-web-development-react-4gpo</guid>
      <description>&lt;p&gt;Every time, I do code day and night, I spend my entire time learning and developing but here I am still making nothing(or just little) from web dev, what should I do?&lt;/p&gt;

&lt;p&gt;Hello my dear reader, I'm Lucas and I'll be giving you tips and tricks to make money from web development in today's post. Stay tuned 😉.&lt;/p&gt;

&lt;p&gt;One of the hardest things in web development is getting a paid job, could be contracts, part-time or full-time, it's not easy. But why? I'll be listing some reasons I got from research below:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Real talents are wanted&lt;/li&gt;
&lt;li&gt;Less job openings in your region&lt;/li&gt;
&lt;li&gt;Years of experience&lt;/li&gt;
&lt;li&gt;You have zero network&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let me take time to talk on each reasons mentioned above.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Real talents are wanted: When we talk about real talents, it means those who have the necessary skills the particular company needs, those who have worked on several projects and have built up several skills from them, that's real talent.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Less job openings in your region: If you find yourself in a location where there are very few startups or tech companies, it could be a challenge.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Years of experience: Even though this shouldn't matter in every situation, a lot of recruiters want people with several years of experience (3-5+ years) working with other companies or so, and this could be really challenging to newbies or junior devs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You have zero network: You could be very skilled, have a very nice portfolio and so on but still have difficulties getting a tangible paid job, why? This is simply because you aren't making yourself known to the necessary set of people/circle. It's not just about randomly posting your recent works to Facebook, Twitter...it goes beyond that. It involves tagging the necessary groups/people, those who will see your work and get in touch with you for business. If you're a student, it's not all about telling your colleagues, it goes to joining tech clubs such as &lt;a href="https://developers.google.com/community/gdsc"&gt;GDSC&lt;/a&gt;, &lt;a href="https://techcommunity.microsoft.com/t5/student-developer-blog/microsoft-student-partner-program-your-questions-answered/ba-p/1034510"&gt;Microsoft student club&lt;/a&gt; and much more out there.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The big question now is, how do I start making money from web development in 2022? 🤔 a very important question.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Partner with the right niche: Reach out to other developers your close to, those who are making money from web dev already and tell them what skills you possess and ask them for help by guiding you as to how you can get your very next big hit. Don't be afraid of doing this, developers love to help each other.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Start utilising LinkedIn: LinkedIn has helped people get employed. Start by uploading your resume and constantly uploading your profile, upload links to your most recent projects. Follow relevant profiles and setup your profile to get job listings.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a personal website: You may find this irrelevant, but it really isn't. Having a personal website says so much about you. You get to put all your recent jobs/projects there, including testimonials from those you've worked with if perhaps you have. Ensure your website isn't unprofessional, don't use just any UI, ensure it looks very professional. Feel free to buy templates or look up some UI you can use.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Start a conversation with small business owners: Do you have a store around you where people go often time? Then that's a big hit for you I say. Walk up to the owner, and introduce yourself, tell them what you've worked on in time past(very necessary) and tell them the advantage of having a website for business(you can just look that up from Google or anywhere 😁) and assure them you can give them the best they can ever ask for. You know what to do from here if you can successfully convince them. Congrats already 🤝&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;DO NOT WORK FOR FREE: I felt I needed to lay emphasises on this. This is very common among beginner developers, you believe "it will build up my portfolio, blah blah blah". No don't work for free. Having this mentality of working for free will really affect you both mentally and physically. Do not care of who the person involved is, the best you can do is give discount in pricing. Ensure you receive a pay on every job you do. (I'll be writing on how to negotiate with clients very soon, if you are excited, let me know in the comment section).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Freelancing: This is a two way thing. If you're not really experienced in web development, I'll advice you do not to go into freelancing just yet. It could be overwhelming and probably discouraging, thereby killing your morale. Rather, meet with people in person(startups, stores, senior developers...) for job vacancy. But if you're confident in your skills and can build big projects, kindly watch tutorials or buy good courses on freelancing for web devs. This will help a lot.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finally, blogging: If you're like me and you love helping young/upcoming developers, writing blog could actually land you a job. Since most of the time you'll be blogging from experience, a recruiter could stumble upon your blog posts, visit your profile(could be LinkedIn or GitHub...) and reach out to you. So you should make it an habit to go into blogging about your stack. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I'll stop here for this post and I really do hope it helps. If it sure did, kindly drop a like and comment on what you think could have been added. Remember to share as well. &lt;/p&gt;

&lt;p&gt;Thank you 🎉&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>React Js roadmap - 2022</title>
      <dc:creator>Samuel Lucas</dc:creator>
      <pubDate>Sat, 01 Jan 2022 01:55:34 +0000</pubDate>
      <link>https://dev.to/sam_lukaa/react-js-roadmap-2022-4p96</link>
      <guid>https://dev.to/sam_lukaa/react-js-roadmap-2022-4p96</guid>
      <description>&lt;p&gt;It's so exhausting trying to figure out where to start or head to while learning something, something like React Js, so much tutorials(videos and PDFs) out there but where exactly is the starting point and what are the things needed to learn so that I can be very good at React Js?&lt;/p&gt;

&lt;p&gt;Hello 👋, I'm Lucas and I'll be walking you through the React Js roadmap for 2022 - here you'll know so what you should learn to become a real react developer, and what you need to apply for the next job.&lt;/p&gt;

&lt;p&gt;The best way to become a pro in this profession is by constantly keeping yourself up-to-date by reading docs of whatever technology you wish to learn. Take for example, if I were to post a tutorial on React, in the next few months it will be outdated because a newer version would be out and surely better, but then the docs would be updated. That's why you should learn to read docs first.&lt;/p&gt;

&lt;p&gt;To develop yourself in React Js, you need certain level of knowledge in JavaScript itself. Let's see what you should know:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Variables&lt;/li&gt;
&lt;li&gt;Functions&lt;/li&gt;
&lt;li&gt;Data Types(objects &amp;amp; arrays)&lt;/li&gt;
&lt;li&gt;Dom manipulation&lt;/li&gt;
&lt;li&gt;Asynchronous&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Knowing these I can assure you success on your journey to learning React Js.&lt;/p&gt;

&lt;p&gt;One of the best places to learn all these from is &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript"&gt;MDN&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What you're expected to know as a React Js developer are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Components&lt;/li&gt;
&lt;li&gt;Routing&lt;/li&gt;
&lt;li&gt;Props&lt;/li&gt;
&lt;li&gt;States&lt;/li&gt;
&lt;li&gt;Inspecting/developer's tools&lt;/li&gt;
&lt;li&gt;Hooks(useState, useEffect, useContext...)&lt;/li&gt;
&lt;li&gt;Redux&lt;/li&gt;
&lt;li&gt;Styling UI (chakra UI, tailwind...)&lt;/li&gt;
&lt;li&gt;Testing(jest...)&lt;/li&gt;
&lt;li&gt;API consumption (a good &lt;a href="https://www.robinwieruch.de/react-hooks-fetch-data/"&gt;recommendation&lt;/a&gt;)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A very good place to learn is from the &lt;a href="https://reactjs.org/tutorial/tutorial.html"&gt;documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ensure you add every of your project to github.&lt;/p&gt;

&lt;p&gt;Some cool projects you can work on are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Weather app (teaches you to fetch api)&lt;/li&gt;
&lt;li&gt;To-do app(teaches you how to pass props and other things)&lt;/li&gt;
&lt;li&gt;E-commerce(teaches you to fetch api and use stores - such as redux. Instead of writing the backend, simply use &lt;a href="https://commercejs.com/"&gt;Commerce Js&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;While doing all these, don't be afraid of applying for jobs. Do not be afraid. Follow good resumẹ́ template. No matter how many times you get turned down, &lt;strong&gt;DO NOT GIVE UP&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Don't be afraid to take on projects(not free, but paid). Why should I take paid projects/contract offers? The moment you collect part payment upon accepting the project, you'll know you've got to just finish it. But if it's unpaid, you might never complete or do it as supposed.&lt;/p&gt;

&lt;p&gt;Talking about projects, how do you start building one? Consider this: I'm a react js developer but projects always seem complex to me, how do I go about with that? &lt;/p&gt;

&lt;p&gt;The most important thing is this; no matter how small or huge the project is, always break it down into components. Example, let's create our very own Facebook.&lt;/p&gt;

&lt;p&gt;What are the features you'll ask? &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;View posts&lt;/li&gt;
&lt;li&gt;Create post&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's assume this is all what it does.&lt;/p&gt;

&lt;p&gt;Knowing this info already, all you need to do is very simple:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a component that fetches (GET) from the API and display the results.&lt;/li&gt;
&lt;li&gt;Create a component that sends (POST) via API - within that component, you'll have input button for the post and send button.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Building with react is very easy if you learn to break things down into components&lt;/p&gt;

&lt;p&gt;Quickly, take this test. Break Twitter home page into components and comment your answer.&lt;/p&gt;

&lt;p&gt;If this post really does help, kindly leave a like and share. Thanks.&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>100daysofcode</category>
    </item>
    <item>
      <title>Reducing nodes in Dom using Fragment - React js</title>
      <dc:creator>Samuel Lucas</dc:creator>
      <pubDate>Thu, 30 Dec 2021 10:42:14 +0000</pubDate>
      <link>https://dev.to/sam_lukaa/reducing-nodes-in-dom-using-fragment-react-js-49c2</link>
      <guid>https://dev.to/sam_lukaa/reducing-nodes-in-dom-using-fragment-react-js-49c2</guid>
      <description>&lt;p&gt;I want to create a component but with minimal nodes added to the dom. How do I do that plus what's the effect of extra/unnecessary nodes getting added to the dom?&lt;/p&gt;

&lt;p&gt;Hello my dear reader, welcome to today's tips and tricks in React. Briefly, we'll see discussing about React fragment, what it is and how it's used. Enjoy 😊&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Fragments let you group a list of children without adding extra nodes to the DOM.&lt;/em&gt; - React official website.&lt;/p&gt;

&lt;p&gt;React Fragments serve as a cleaner alternative to using unnecessary divs in your code.&lt;/p&gt;

&lt;p&gt;Using divs in Fragments place, you tend to get UI malfunctions and unnecessary nodes added to the dom.&lt;/p&gt;

&lt;p&gt;The question now is, how do I use it⁉️&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;import&lt;/span&gt; &lt;span class="nx"&gt;React&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&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;Fragments&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h5&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Applying&lt;/span&gt; &lt;span class="nx"&gt;Fragments&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h5&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;This&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;simple&lt;/span&gt; &lt;span class="nx"&gt;way&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;doing&lt;/span&gt; &lt;span class="nx"&gt;it&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/React. Fragments&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or better still&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="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h5&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Applying&lt;/span&gt; &lt;span class="nx"&gt;Fragments&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h5&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;This&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;simpler&lt;/span&gt; &lt;span class="nx"&gt;way&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;doing&lt;/span&gt; &lt;span class="nx"&gt;it&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Not using fragments:&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h5&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Not&lt;/span&gt; &lt;span class="nx"&gt;applying&lt;/span&gt; &lt;span class="nx"&gt;Fragments&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h5&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;This&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;the&lt;/span&gt; &lt;span class="nx"&gt;casual&lt;/span&gt; &lt;span class="nx"&gt;way&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;doing&lt;/span&gt; &lt;span class="nx"&gt;it&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you render the dom for the first two, you get something like this, which is cleaner:&lt;br&gt;
&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;h5&amp;gt;&lt;/span&gt;Applying Fragments&lt;span class="nt"&gt;&amp;lt;/h5&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;This is a simple way of doing it&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But for that with &lt;code&gt;div&lt;/code&gt;, you get something like this, which can cause certain inconsistency in your UI:&lt;br&gt;
&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;div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;h5&amp;gt;&lt;/span&gt;Not applying Fragments&lt;span class="nt"&gt;&amp;lt;/h5&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;This is the casual way of doing it&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The difference between the first two, i.e &lt;code&gt;&amp;lt;React. Fragments&amp;gt;...&amp;lt;/React. Fragments&amp;gt;&lt;/code&gt; &amp;amp; &lt;code&gt;&amp;lt;&amp;gt;...&amp;lt;/&amp;gt;&lt;/code&gt; is that, just in case you want to pass a &lt;code&gt;key&lt;/code&gt; prop maybe after mapping through an array, you can achieve that only with &lt;code&gt;&amp;lt;React. Fragments key={...}&amp;gt;...&amp;lt;/React. Fragments&amp;gt;&lt;/code&gt; and not the other one.&lt;/p&gt;

&lt;p&gt;For more info on React fragment, kindly read the official docs: &lt;a href="https://reactjs.org/docs/fragments.html"&gt;https://reactjs.org/docs/fragments.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have you been using fragments or you're just getting to know if it? Let me know in the comment section.&lt;/p&gt;

&lt;p&gt;Kindly drop a like and share if it helped.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>100daysofcode</category>
    </item>
    <item>
      <title>Handling form input in React(including drop-down and checkbox)</title>
      <dc:creator>Samuel Lucas</dc:creator>
      <pubDate>Wed, 29 Dec 2021 23:37:51 +0000</pubDate>
      <link>https://dev.to/sam_lukaa/handling-form-input-in-reactincluding-drop-down-and-checkbox-47h8</link>
      <guid>https://dev.to/sam_lukaa/handling-form-input-in-reactincluding-drop-down-and-checkbox-47h8</guid>
      <description>&lt;p&gt;I have a form that requests for user's details - username and password, how do I get them in react?&lt;/p&gt;

&lt;p&gt;Hello my dear reader, my name's Lucas and today we'll be solving the problem above and beyond that.&lt;/p&gt;

&lt;p&gt;To start with, I need you to know that the way you create forms in react is very similar to that of vanilla html. Let's create a simple login form.&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;form&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h3&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h3&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;  &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;

  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h3&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h3&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/form&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the simple form we'll be using.&lt;/p&gt;

&lt;p&gt;Let's start by creating a state for each input, with empty string to start with&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;initialData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setUserData&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="nx"&gt;initialData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, we destructure the state so that we can interact with its data.&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="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What we'll be doing next is this. We want to recognize each input by their names, so we will be giving both of them a corresponding name plus we'll also set the values to the state's value(&lt;strong&gt;username&lt;/strong&gt; and &lt;strong&gt;password&lt;/strong&gt; in &lt;em&gt;useState()&lt;/em&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;form&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h3&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h3&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&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="s2"&gt;username&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h3&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h3&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&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="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/form&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Up next, we'll create a function that updates &lt;strong&gt;setUserData&lt;/strong&gt; whenever there's a change within it.&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;onChangeHandler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;setUserData&lt;/span&gt;&lt;span class="p"&gt;({...&lt;/span&gt; &lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or shorter&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;onChangeHandler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="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;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;setUserData&lt;/span&gt;&lt;span class="p"&gt;({...&lt;/span&gt; &lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt; &lt;span class="nx"&gt;value&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;userData&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;Finally all we've got to do is attach the function to each input.&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;form&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h3&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h3&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&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="s2"&gt;username&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;onChangeHandler&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h3&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h3&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&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="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;onChangeHandler&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/form&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I really love to do for checkbox but then I discovered it will be interesting if you tried it out yourself, using this example. Let me know in the comment section if you did it. I'd be glad to know.&lt;/p&gt;

&lt;p&gt;To read and understand more about this topic, visit Reacts official website: &lt;a href="https://reactjs.org/docs/forms.html"&gt;https://reactjs.org/docs/forms.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Did you find this post helpful? Why not give it a like and share with others. 😉&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>react</category>
      <category>100daysofcode</category>
    </item>
    <item>
      <title>Conditional rendering in React</title>
      <dc:creator>Samuel Lucas</dc:creator>
      <pubDate>Wed, 29 Dec 2021 10:17:31 +0000</pubDate>
      <link>https://dev.to/sam_lukaa/conditional-rendering-in-react-2cjb</link>
      <guid>https://dev.to/sam_lukaa/conditional-rendering-in-react-2cjb</guid>
      <description>&lt;p&gt;Real quick, I have two components I want to render(show) based on the role of login status, if it's an admin then I want to display the admin UI or else if it's a user, display the user UI. &lt;br&gt;
How do I do this?&lt;/p&gt;

&lt;p&gt;Hello my dear reader, welcome to today's post where I'll be teaching the tricks and tips to solve the problem above. Enjoy you stay reading the post 📯.&lt;/p&gt;

&lt;p&gt;When you have components you want to conditionally render, React has a way of helping you achieve that. Let's see it in action.&lt;/p&gt;

&lt;p&gt;Let's use the problem above as an example. Say we have Admin &amp;amp; User components.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
{
  return ({user &amp;amp;&amp;amp; user.role === 
   "Admin" ? &amp;lt;Admin /&amp;gt; : &amp;lt;User /&amp;gt;})
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So what's going on here. If a user is logged in, he's either having a role of &lt;strong&gt;User&lt;/strong&gt; or &lt;strong&gt;Admin&lt;/strong&gt;. Now we checked if there's a user, if there's one, check for the role and display the corresponding UI.&lt;/p&gt;

&lt;p&gt;What about a situation where it's just a component you want to render?&lt;br&gt;
Let's take a scenario where you want to display an error if password attempt's more than 3 times.&lt;/p&gt;

&lt;p&gt;Simply do this in your return block:&lt;br&gt;
Assume you have a variable called &lt;code&gt;attempt&lt;/code&gt; holding the number of times the user tried logging in, and a component called &lt;code&gt;ErrorToast&lt;/code&gt; that will display the error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return({attempt &amp;gt;= 3 ? &amp;lt;ErrorToast /&amp;gt; : null})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are saying if the attempt is 3 times already, display the error if not, do nothing.&lt;/p&gt;

&lt;p&gt;Or the easier way&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;And that's all for now. &lt;br&gt;
If you did learn something, kindly share and give it a like 😉&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>100daysofcode</category>
    </item>
    <item>
      <title>Error boundaries in React</title>
      <dc:creator>Samuel Lucas</dc:creator>
      <pubDate>Tue, 28 Dec 2021 14:40:03 +0000</pubDate>
      <link>https://dev.to/sam_lukaa/error-boundaries-in-react-11l</link>
      <guid>https://dev.to/sam_lukaa/error-boundaries-in-react-11l</guid>
      <description>&lt;p&gt;Hello my dear reader, enjoy your stay reading today's content.&lt;/p&gt;

&lt;p&gt;Let begin with knowing what error boundaries are. Simply, they are react components that catch errors from your code, log them and display the UI you set for error(fallback).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How can this be of help to you?&lt;/strong&gt;&lt;br&gt;
Whenever you have a break(💔) in your UI, this helps discover it and effect an action immediately. Error boundaries catch errors during rendering, in lifecycle methods, and in constructors of the whole tree below them.&lt;br&gt;
For example, Facebook Messenger wraps content of the sidebar, the info panel, the conversation log, and the message input into separate error boundaries. If some component in one of these UI areas crashes, the rest of them remain interactive.&lt;/p&gt;

&lt;p&gt;Read more on error boundary on the react official website. &lt;a href="https://reactjs.org/docs/error-boundaries.html"&gt;https://reactjs.org/docs/error-boundaries.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do you use it?&lt;/strong&gt;&lt;br&gt;
You can implement error boundary in react hooks with the help of react-error-boundary package.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install --save react-error-boundary&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then:&lt;br&gt;
&lt;code&gt;import {ErrorBoundary} from 'react-error-boundary'&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function ErrorFallback({error, resetErrorBoundary}) {
  return (
    &amp;lt;div role="alert"&amp;gt;
      &amp;lt;p&amp;gt;Something went wrong:&amp;lt;/p&amp;gt;
      &amp;lt;pre&amp;gt;{error.message}&amp;lt;/pre&amp;gt;
      &amp;lt;button onClick={resetErrorBoundary}&amp;gt;Try again&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const ui = (
  &amp;lt;ErrorBoundary
    FallbackComponent={ErrorFallback}
    onReset={() =&amp;gt; {
      // reset the state of your app so the error doesn't happen again
    }}
  &amp;gt;
    &amp;lt;ComponentThatMayError /&amp;gt;
  &amp;lt;/ErrorBoundary&amp;gt;
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Good news is this just the tip of an iceberg, read the full docs to see more awesome features&lt;br&gt;
&lt;a href="https://www.npmjs.com/package/react-error-boundary"&gt;https://www.npmjs.com/package/react-error-boundary&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There we have it for this trick and tips in React hooks.&lt;/p&gt;

&lt;p&gt;If this blog post helps, kindly give it a like and share. Thanks.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>reacthooks</category>
      <category>wwebdev</category>
    </item>
    <item>
      <title>How to use fetch in JavaScript</title>
      <dc:creator>Samuel Lucas</dc:creator>
      <pubDate>Mon, 27 Dec 2021 09:43:00 +0000</pubDate>
      <link>https://dev.to/sam_lukaa/how-to-use-fetch-in-javascript-4lma</link>
      <guid>https://dev.to/sam_lukaa/how-to-use-fetch-in-javascript-4lma</guid>
      <description>&lt;p&gt;You received a project that you're needed to fetch data from an API and you've got no idea about it, well I'm here to teach you the necessary tricks to get started.&lt;/p&gt;

&lt;p&gt;To fetch, wait what's fetch? There are several definitions there but they just aren't simple enough. &lt;/p&gt;

&lt;p&gt;Simply, fetch is a way to interact with the database; pass information between frontend and backend.&lt;/p&gt;

&lt;p&gt;There are different ways to do this, we have GET, POST, PUT &amp;amp; DELETE. Let's talk a bit about them.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;GET: Just as the name implies, it is a way to get data through the API to the frontend.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;POST: Well it's still as its name implies. This time you're sending data you created to backend through the API, could be an image or text it any other thing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PUT: It's very similar to POST just that in the case your updating a data and then sending it back to the backend.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;DELETE: Yep, it's just deleting data from the backend via API.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use case for each.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;GET: It receives a single parameter and that's the endpoint you're wanting to fetch data from.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch("https://endpoint.com")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;POST &amp;amp; PUT: The fetch() method can optionally accept a second parameter, an init object that allows you to control a number of different settings
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const data = { username: 'example' };

fetch('https://example.com/profile', {
  method: 'POST', // or 'PUT'
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(data),
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To know more about this, read up on &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch"&gt;https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;DELETE: The fetch() method can optionally accept a second parameter, an init object that allows you to control the method and headers
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch('https://example.com/profile', {
  method: 'DELETE',
  headers: {
    'Content-Type': 'application/json',
  }
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To know more about this, read up on &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch"&gt;https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There you go. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>fetch</category>
      <category>api</category>
    </item>
    <item>
      <title>Creating variables in JavaScript</title>
      <dc:creator>Samuel Lucas</dc:creator>
      <pubDate>Mon, 27 Dec 2021 08:36:18 +0000</pubDate>
      <link>https://dev.to/sam_lukaa/creating-variables-in-javascript-81e</link>
      <guid>https://dev.to/sam_lukaa/creating-variables-in-javascript-81e</guid>
      <description>&lt;p&gt;Variables: what are variables? A variable can be thought of as a container that stores items. &lt;/p&gt;

&lt;p&gt;There are two types of variables, you have one which you can reassign values to and another which you can't reassign values to.&lt;/p&gt;

&lt;p&gt;Let's see the different variables we have with examples and how they function.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;1. var&lt;/em&gt;&lt;br&gt;
✅ how to use: &lt;code&gt;var name = "Lucas"&lt;/code&gt;&lt;br&gt;
✅ function: it is a "reassignable" variable. Meaning you can do something like this in your code&lt;br&gt;
&lt;code&gt;var name = 'Lucas'&lt;/code&gt;&lt;br&gt;
&lt;code&gt;var name = 'Samuel'&lt;/code&gt;&lt;br&gt;
The result is that the variable &lt;em&gt;name&lt;/em&gt; will hold the last assigned item, meaning it will hold &lt;em&gt;Samuel&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;2. let&lt;/em&gt;&lt;br&gt;
✅ how to use: &lt;code&gt;let name = "Lucas"&lt;/code&gt;&lt;br&gt;
✅ function: it is a "reassignable" variable. Meaning you can do something like this in your code&lt;br&gt;
&lt;code&gt;let name = 'Lucas'&lt;/code&gt;&lt;br&gt;
&lt;code&gt;let name = 'Samuel'&lt;/code&gt;&lt;br&gt;
The result is that the variable &lt;em&gt;name&lt;/em&gt; will hold the last assigned item, meaning it will hold &lt;em&gt;Samuel&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;3. const&lt;/em&gt;&lt;br&gt;
✅ how to use: &lt;code&gt;const name = "Lucas"&lt;/code&gt;&lt;br&gt;
✅ function: it is a "non reassignable" variable. Meaning you &lt;em&gt;cannot&lt;/em&gt; do something like this in your code&lt;br&gt;
&lt;code&gt;const name = 'Lucas'&lt;/code&gt;&lt;br&gt;
&lt;code&gt;const name = 'Samuel'&lt;/code&gt;&lt;br&gt;
An error will occur that you cannot reassign values it items to name.&lt;/p&gt;

&lt;p&gt;There's a catch to &lt;strong&gt;var&lt;/strong&gt; tho' and that's the fact that it's no longer in use from the previous es6.&lt;/p&gt;

&lt;p&gt;Why? I don't know as well 🤷, just kidding. Read it up from here to learn more. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>React hooks</title>
      <dc:creator>Samuel Lucas</dc:creator>
      <pubDate>Sun, 26 Dec 2021 22:35:17 +0000</pubDate>
      <link>https://dev.to/sam_lukaa/react-hooks-22d4</link>
      <guid>https://dev.to/sam_lukaa/react-hooks-22d4</guid>
      <description>&lt;p&gt;React hooks...what is this? Yep, I know you might have heard of it some how, somewhere but don't have complete knowledge of what it is, if that's the case fear not I'm here to break it down to you the simplest way to digest it.&lt;/p&gt;

&lt;p&gt;Let's start with React itself. What is React? In a simple word, it is a JavaScript framework that allows you to write your code easier and faster by reducing the amount of code you have to write, through the already made functions you can call and use; rather than creating yours afresh.. Oh that's a lot.&lt;/p&gt;

&lt;p&gt;Now what are hooks? Hooks are now special functions that allow you to access some special functions in react; which will greatly minimize how many lines of code you write.&lt;/p&gt;

&lt;p&gt;Let's see some examples that will make it simpler to understand.&lt;/p&gt;

&lt;p&gt;Take for example, you want a particular section of your code to run immediately a page loads, you apply &lt;code&gt;useEffect()&lt;/code&gt; function in react by importing it as in &lt;code&gt;import {useEffect} from react&lt;/code&gt;.&lt;br&gt;
Taking this React function as an example, you can call a function or a part of your code whenever, for example you can have an e-commerce and you want the cart items to increment when a user adds an item to cart, all you do is to check if the increment button was clicked and if it's clicked, increment the cart items by 1. Very simple and basic.&lt;/p&gt;

&lt;p&gt;This is just a basic introduction to hooks, you can learn more from the official site &lt;a href="https://reactjs.org/docs/hooks-intro.html"&gt;https://reactjs.org/docs/hooks-intro.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>hooks</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
