<?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: Hermes</title>
    <description>The latest articles on DEV Community by Hermes (@truepadawan).</description>
    <link>https://dev.to/truepadawan</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%2F666669%2Fd04cfadf-2398-4c57-a69e-786caa387805.png</url>
      <title>DEV Community: Hermes</title>
      <link>https://dev.to/truepadawan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/truepadawan"/>
    <language>en</language>
    <item>
      <title>Understanding flex-basis and flex-grow</title>
      <dc:creator>Hermes</dc:creator>
      <pubDate>Fri, 03 Dec 2021 01:49:06 +0000</pubDate>
      <link>https://dev.to/truepadawan/understanding-flex-basis-and-flex-grow-41a0</link>
      <guid>https://dev.to/truepadawan/understanding-flex-basis-and-flex-grow-41a0</guid>
      <description>&lt;p&gt;I recently started The Odin Project and I hit a wall during the FlexBox section. I had a bit of trouble understanding exactly how &lt;code&gt;flex-basis&lt;/code&gt; in particular functioned relative to different &lt;code&gt;flex-grow&lt;/code&gt; and &lt;code&gt;flex-shrink&lt;/code&gt; values so after going taking time to go through different resources, I've found a way that helped me understand which is just through a bit of ratio math.&lt;/p&gt;

&lt;h2&gt;
  
  
  Terminologies
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;flex-basis&lt;/code&gt; - This defines the default size of an element before the remaining space is distributed. It can be a length (e.g. 20%, 5rem, etc.) or a keyword. Default value of &lt;code&gt;auto&lt;/code&gt; which takes width/height instead depending on &lt;code&gt;flex-direction&lt;/code&gt;. If no width/height is set then it uses the content size.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;flex-grow&lt;/code&gt; - This defines the ability for a flex item to grow if necessary. It accepts a unitless value that serves as a proportion. It dictates what amount of the available space inside the flex container the item should take up. Default value of 0.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/truepadawan/embed/yLzBvzZ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;You can think of &lt;code&gt;flex-basis&lt;/code&gt; as a virtual width or the width that the entire flex system sees relative to a particular element. Set a flex-basis of &lt;code&gt;50px&lt;/code&gt; to the fourth element and observe the change.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The boxes are colored along with the container to show you changes in width/increase in available space in container&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The 4th box decreases in size by &lt;code&gt;50px&lt;/code&gt; and the available space increases &lt;code&gt;+50px&lt;/code&gt;. It basically put up part of its width as being free to take. If the code were running on your browser natively and you checked the flex section in your developer tools, you would see something like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NKal4OlU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k27ijeppv1gvcvvs9brb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NKal4OlU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k27ijeppv1gvcvvs9brb.png" alt="Image description" width="497" height="207"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice how the final size says &lt;code&gt;50px&lt;/code&gt; , comment out the &lt;code&gt;flex-basis&lt;/code&gt; styling and notice it goes back to the set width which is because the default value of &lt;code&gt;flex-basis&lt;/code&gt; is &lt;code&gt;auto&lt;/code&gt; and so it defaults to the width of the item.&lt;/p&gt;

&lt;p&gt;Now add the &lt;code&gt;flex-basis&lt;/code&gt; styling back and then set a &lt;code&gt;flex-grow&lt;/code&gt; of 1 to the box and observe the changes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dyTGZRNW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vvc9prqrohaj7bqhbfoo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dyTGZRNW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vvc9prqrohaj7bqhbfoo.png" alt="Image description" width="498" height="260"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By increasing its &lt;code&gt;flex-grow&lt;/code&gt;, we've given it permission to &lt;code&gt;grow&lt;/code&gt; and essentially take up any &lt;code&gt;available space&lt;/code&gt; . Notice that it takes up the &lt;code&gt;150px&lt;/code&gt; space that is available.&lt;/p&gt;

&lt;p&gt;Like before, temporarily comment out &lt;code&gt;flex-basis&lt;/code&gt; and see what changes, this time since it's width is back to &lt;code&gt;100px&lt;/code&gt; , the available space is &lt;code&gt;100px&lt;/code&gt; and it still takes it all. Add the &lt;code&gt;flex-basis&lt;/code&gt; value back.&lt;/p&gt;

&lt;p&gt;Set a &lt;code&gt;flex-grow&lt;/code&gt; of &lt;code&gt;1&lt;/code&gt; to the 3rd box and observe the changes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dpv-K0Za--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7rk0t65ph2cxxr81urdn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dpv-K0Za--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7rk0t65ph2cxxr81urdn.png" alt="Image description" width="500" height="244"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2y8qLoQR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cyhn0mtwxajdck8fhpmi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2y8qLoQR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cyhn0mtwxajdck8fhpmi.png" alt="Image description" width="500" height="267"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This time the 4th box takes only &lt;code&gt;75px&lt;/code&gt; of space, same goes for the third box. Why? Well, now we gave the 3rd box permission to grow and it will do that. It will want to take a piece out of the available space just like the 4th does. How do they decide how the space is allocated? simply by ratio.&lt;/p&gt;

&lt;p&gt;Assume the &lt;code&gt;flex-grow&lt;/code&gt; values of items in a flex-container as a ratio of how much available space it will get.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Box #1 - 0&lt;/code&gt;  &lt;code&gt;Box #2 - 0&lt;/code&gt;  &lt;code&gt;Box #3 - 1&lt;/code&gt;  &lt;code&gt;Box #4 - 1&lt;/code&gt;  &lt;code&gt;free space - 150px&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;What is listed above is the &lt;code&gt;flex-grow&lt;/code&gt; values for the items in the flex container and the available space in the container. Lets see some simple ratio math.&lt;/p&gt;

&lt;h3&gt;
  
  
  Box #1
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;(0/(0+0+1+1)) * 150px = 0px&lt;/code&gt; Box 1 = 100px + 0px.&lt;/p&gt;

&lt;h3&gt;
  
  
  Box #2
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;(0/(0+0+1+1)) * 150px = 0px&lt;/code&gt; Box 2 = 100px + 0px.&lt;/p&gt;

&lt;h3&gt;
  
  
  Box #3
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;(1/(0+0+1+1)) * 150px = 75px&lt;/code&gt; Box 3 = 100px + 75px&lt;/p&gt;

&lt;h3&gt;
  
  
  Box #4
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;(1/(0+0+1+1)) * 150px = 75px&lt;/code&gt; Box 4 = 50px + 75px&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Remember Box 4 lost 50px of its width when it set its &lt;code&gt;flex-basis&lt;/code&gt; to 50px&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As you can see,  rather than box 3 and 4 splitting 100px which is the available space by default, they ended up splitting up 150px because has a &lt;code&gt;flex-basis&lt;/code&gt; of &lt;code&gt;50px&lt;/code&gt; which you can interpret as having a perceived width(in terms of the entire flex system) of 50px.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If two elements have the same flex-grow value, they will receive the same amount of space from the available space.(in most cases)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Lets spice things up a bit, don't revert any current chances to the css code, give the 1st box a flex basis of &lt;code&gt;80px&lt;/code&gt; and a &lt;code&gt;flex-grow&lt;/code&gt; of &lt;code&gt;1&lt;/code&gt;, also give Box 2 a &lt;code&gt;flex-grow&lt;/code&gt; of &lt;code&gt;2&lt;/code&gt;. Using the previous approach, you can deduce how much space will be allocated to each element.&lt;/p&gt;

&lt;p&gt;Now that Box 1 has a flex-basis of &lt;code&gt;80px&lt;/code&gt;,you can say its adding &lt;code&gt;20px&lt;/code&gt; of its width to the available space. So now the available space becomes &lt;code&gt;100px + 50px + 20px&lt;/code&gt; = &lt;code&gt;170px&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Box #1
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;(1/(1+2+1+1)) * 170px = 34px&lt;/code&gt; Box 1 = 80px + 34px = 114px&lt;/p&gt;

&lt;h3&gt;
  
  
  Box #2
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;(2/(1+2+1+1)) * 170px = 68px&lt;/code&gt; Box 2 = 100px + 68px = 168px&lt;/p&gt;

&lt;h3&gt;
  
  
  Box #3
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;(1/(1+2+1+1)) * 170px = 34px&lt;/code&gt; Box 3 = 100px + 34px = 134px&lt;/p&gt;

&lt;h3&gt;
  
  
  Box #4
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;(1/(1+2+1+1)) * 170px = 34px&lt;/code&gt; Box 4 = 50px + 34px = 84px&lt;/p&gt;

&lt;p&gt;You can see the new width of the boxes, it can be verified through the developer tools or you can set the width of that black box and check it against each of the flex items by moving it around in its container.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--j4G7l4-h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jbpo5mi7zpghukutt3gr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j4G7l4-h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jbpo5mi7zpghukutt3gr.png" alt="Flex Info" width="494" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZpGmRfhd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7mi58xfe7mvbab8bw3jp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZpGmRfhd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7mi58xfe7mvbab8bw3jp.png" alt="Image description" width="497" height="238"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kQB5A9N6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g66r76fcuberr7tu5qm0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kQB5A9N6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g66r76fcuberr7tu5qm0.png" alt="Image description" width="499" height="232"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7o3et-Lb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z12hxovd53le9mmacvr7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7o3et-Lb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z12hxovd53le9mmacvr7.png" alt="Image description" width="504" height="254"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that if we increased the &lt;code&gt;flex-basis&lt;/code&gt; of an item here higher than its own width, it will increase in width in this flex system. To get the increase in width, just get the difference between its set width and the &lt;code&gt;flex-basis&lt;/code&gt; . If it has a &lt;code&gt;flex-grow&lt;/code&gt; higher than 0, the same ratio approach will still work as long as you realize that the specific item basically &lt;code&gt;took a chunk out of the available space&lt;/code&gt; before the allocation of space to all items begins.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
      <category>css</category>
    </item>
    <item>
      <title>[React] Rendering dynamic list of content</title>
      <dc:creator>Hermes</dc:creator>
      <pubDate>Tue, 02 Nov 2021 07:23:19 +0000</pubDate>
      <link>https://dev.to/truepadawan/react-rendering-dynamic-list-of-content-10b9</link>
      <guid>https://dev.to/truepadawan/react-rendering-dynamic-list-of-content-10b9</guid>
      <description>&lt;p&gt;OK so we have a project and in that project, we want to render some list of data that is dynamic and for example changes when the user clicks a button. Lets see how this is done in react, it's quite straightforward and you can probably already guess that it involves the use of states.&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%2Fr5soep76l2pguuqvndk8.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr5soep76l2pguuqvndk8.gif" alt="Dynamic list"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm going to use a very basic project I prepared to illustrate this topic. A simple react app that lets the user to input some text and it gets rendered on the screen for the user to see.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Take a look at the full source code &lt;a href="https://codesandbox.io/s/goals-project-l8xkl" rel="noopener noreferrer"&gt;here&lt;/a&gt; because I'm not going through how to build the entire project, only the rendering of the dynamic list of data.&lt;/b&gt;&lt;/p&gt;

&lt;h3&gt;Project Structure&lt;/h3&gt;

&lt;ul&gt;
    &lt;li&gt;Body
       &lt;ul&gt;
           &lt;li&gt;Body.js&lt;/li&gt;
           &lt;li&gt;Body.css&lt;/li&gt;
       &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;Card
        &lt;ul&gt;
           &lt;li&gt;Card.js&lt;/li&gt;
           &lt;li&gt;Card.css&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;App.js&lt;/li&gt;
    &lt;li&gt;index.js&lt;/li&gt;
    &lt;li&gt;styles.css&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;Card - &lt;/b&gt; A component which is meant to house other components and give them a sort of cover.(Bad naming on my part I guess)&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./Card.css&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="nx"&gt;Card&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&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="nx"&gt;classes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;card &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;return&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="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;classes&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;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;children&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&amp;gt;&lt;/span&gt;&lt;span class="err"&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="nx"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


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

&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;The &lt;code&gt;children&lt;/code&gt; prop is a default prop that returns whatever is the component encapsulates. In this case it will return the other components that are encapsulated by the &lt;code&gt;Card&lt;/code&gt; component and put them in a div&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;b&gt;Goal - &lt;/b&gt;The component which handles the dynamic list of data.&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;Card&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;../Card/Card&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./Goal.css&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="nx"&gt;Goal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&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;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;indiv&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Card&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;set-goal&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;indiv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;indiv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_output&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;/Card&lt;/span&gt;&lt;span class="err"&gt;&amp;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="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;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Goal&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


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

&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;This component takes the list of dynamic content as a prop(&lt;code&gt;items&lt;/code&gt; which will be a state) and encapsulates the all of the items in the list with the &lt;code&gt;Card&lt;/code&gt; component.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;b&gt;Body - &lt;/b&gt; The main component where the other components are brought together to form the app.&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;goalsList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;_output&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="p"&gt;];&lt;/span&gt;

&lt;span class="c1"&gt;// TESTING STYLED COMPONENTS LIB, GOAL INPUT IS A COMPONENT WITH ITS OWN UNIQUE STYLING&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;GoalInput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="s2"&gt;`
  background-color: &lt;/span&gt;&lt;span class="p"&gt;${(&lt;/span&gt;&lt;span class="nx"&gt;props&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;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;invalid&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bisque&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;transparent&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="s2"&gt;;
  border-color: &lt;/span&gt;&lt;span class="p"&gt;${(&lt;/span&gt;&lt;span class="nx"&gt;props&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;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;invalid&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;red&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;beige&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="s2"&gt;;
  border-width: 1px;
  width: 85%;
  height: 1.5rem;

  &amp;amp;:focus {
    outline: none;
  }
`&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;Body&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="c1"&gt;// STATES USED IN THE APP&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;goals&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setGoals&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;goalsList&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;isValid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setIsValid&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// CALLED WHEN THE TEXT IN THE INPUT ELEMENT CHANGES&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;validGoalsInput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setIsValid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setIsValid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="c1"&gt;// CALLED WHEN THE USER CLICKS THE ADD BUTTON&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;addHandler&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;goalText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;goalText&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="c1"&gt;// UPDATE THE LIST OF GOALS STATE IF THE INPUT ISNT EMPTY/WHITESPACE OR JUST A CHARACTER&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;goalText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isValid&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;setIsValid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="nf"&gt;setGoals&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;prevGoals&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;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prevGoals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;prevGoals&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;_output&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
              &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="na"&gt;_output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;goalText&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;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
              &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;prevGoals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="na"&gt;_output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;goalText&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;span class="nx"&gt;prevGoals&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;goalText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setIsValid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="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="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;Card&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;card-body&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;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;goals-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="nx"&gt;My&lt;/span&gt; &lt;span class="nx"&gt;Goals&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="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;GoalInput&lt;/span&gt;
            &lt;span class="nx"&gt;invalid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;isValid&lt;/span&gt;&lt;span class="p"&gt;}&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;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;goalText&lt;/span&gt;&lt;span class="dl"&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;validGoalsInput&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;/div&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;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;goals-button&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;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;addHandler&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Add&lt;/span&gt; &lt;span class="nx"&gt;Goal&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&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;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Card&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;Goal&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;goals&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;/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;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Body&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


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

&lt;/div&gt;
&lt;p&gt;We want to render a 'list' of content so we create a dummy array &lt;code&gt;goalsList&lt;/code&gt; which has one js object in it. The array will serve as the initial value of the state which holds the dynamic list of content. It has a &lt;code&gt;key&lt;/code&gt; and &lt;code&gt;_output&lt;/code&gt; attribute.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;key&lt;/code&gt; attribute is just there as a best practice, we will use it to allow React to render our list efficiently.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;_output&lt;/code&gt; attribute will contain the text which the user inputs in the react app.&lt;/p&gt;

&lt;p&gt;The next piece of code isn't important to the topic; just me getting to know how to use the &lt;code&gt;styled components&lt;/code&gt; external lib.&lt;/p&gt;

&lt;p&gt;So straight into our &lt;code&gt;Body&lt;/code&gt; component, we define two state variables;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;goals - The state which holds our dynamic list&lt;/p&gt;

&lt;p&gt;isValid - This state will be a boolean which tells us if what the user inputted is valid&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;b&gt;Lets skip the other code for now and jump straight to the structure of the &lt;code&gt;Body&lt;/code&gt; component.&lt;/b&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;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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Card&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;card-body&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;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;goals-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="nx"&gt;My&lt;/span&gt; &lt;span class="nx"&gt;Goals&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="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;GoalInput&lt;/span&gt;
            &lt;span class="nx"&gt;invalid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;isValid&lt;/span&gt;&lt;span class="p"&gt;}&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;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;goalText&lt;/span&gt;&lt;span class="dl"&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;validGoalsInput&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;/div&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;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;goals-button&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;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;addHandler&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Add&lt;/span&gt; &lt;span class="nx"&gt;Goal&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&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;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Card&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;Goal&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;goals&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;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;


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

&lt;/div&gt;
&lt;p&gt;The structure should be clear from just looking at the code itself, &lt;code&gt;GoalInput&lt;/code&gt; is just a styled component(created with &lt;code&gt;styled component&lt;/code&gt; lib) encapsulated in a &lt;code&gt;Card&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It takes a prop &lt;code&gt;invalid&lt;/code&gt; which is used for dynamic styling.&lt;br&gt;
It determines when we add a different styling to the input element based on the value of the &lt;code&gt;isValid&lt;/code&gt; state which tells us whether what the user inputted is valid or not.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;onChange&lt;/code&gt; event triggers when the value our input element changes.&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;validGoalsInput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setIsValid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setIsValid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;


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

&lt;/div&gt;
&lt;p&gt;We're calling an event handler which just sets the boolean value of the &lt;code&gt;isValid&lt;/code&gt; state based on whether the user input is empty, one character, or whitespace.&lt;/p&gt;

&lt;p&gt;Then there's the &lt;code&gt;Goal&lt;/code&gt; component which handles our dynamic list and a simple button with an event handler &lt;code&gt;addHandler&lt;/code&gt; set for when it is clicked.&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;addHandler&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;goalText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;goalText&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="c1"&gt;// UPDATE THE LIST OF GOALS STATE IF THE INPUT ISNT EMPTY/WHITESPACE OR JUST A CHARACTER&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isValid&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setGoals&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;prevGoals&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;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prevGoals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;prevGoals&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;_output&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
              &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="na"&gt;_output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;goalText&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;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
              &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;prevGoals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="na"&gt;_output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;goalText&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;span class="nx"&gt;prevGoals&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;goalText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;


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

&lt;/div&gt;
&lt;p&gt;First we get the input element through its id and keep that in a variable, then we check if the &lt;code&gt;isValid&lt;/code&gt; prop is set to true, that would indicate that what is currently in the input element is valid.&lt;/p&gt;

&lt;p&gt;If it's valid, we update the &lt;code&gt;goals&lt;/code&gt; state; We check if we're currently adding the first actual content apart from the dummy value in the state, if yes then we simply return an array which contains only one item effectively overwriting the dummy value. &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;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
              &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="na"&gt;_output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;goalText&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;If no, we return an array which contains a new item and the previous values in the state, thereby updating our &lt;code&gt;goals&lt;/code&gt; state with new data. The value in the input element is cleared after that.&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;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
              &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;prevGoals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="na"&gt;_output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;goalText&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;span class="nx"&gt;prevGoals&lt;/span&gt;
          &lt;span class="p"&gt;];&lt;/span&gt;


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

&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;When you're updating a state and you're depending on the current value of the state before it is updated, you should wrap the entire update process in a function which takes a parameter; the parameter being the current value of the state.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="nf"&gt;setGoals&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;prevGoals&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;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prevGoals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;prevGoals&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;_output&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
              &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="na"&gt;_output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;goalText&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;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
              &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;prevGoals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="na"&gt;_output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;goalText&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;span class="nx"&gt;prevGoals&lt;/span&gt;
          &lt;span class="p"&gt;];&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;


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

&lt;/div&gt;
&lt;p&gt;&lt;b&gt;Notice how the entire updating process is in a function which takes a parameter &lt;code&gt;prevGoals&lt;/code&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;goals&lt;/code&gt; state is passed to the &lt;code&gt;Goals&lt;/code&gt; Component as a prop &lt;code&gt;item&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The component uses &lt;code&gt;map()&lt;/code&gt; to apply a &lt;code&gt;Card&lt;/code&gt; component with a unique class that sets the styling.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;key&lt;/code&gt; prop is a default prop that is available to Components by default. It's used in a scenario like this where we're rendering an array/list of content. It enables React to render the list effectively, giving each item in the array a sort of unique identity.&lt;/p&gt;

&lt;p&gt;Without the key prop everything will still work fine but there can be some performance loss(in large scale apps, ours is too small to notice any performance hiccups)&lt;/p&gt;

&lt;p&gt;&lt;b&gt;A more in-depth explanation of the key prop can be gotten from in the article below&lt;/b&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag__link"&gt;
  &lt;a href="/francodalessio" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&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%2Fuser%2Fprofile_image%2F357813%2F0dd39184-6866-4fea-abff-67dea926feb1.jpeg" alt="francodalessio"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/francodalessio/understanding-the-importance-of-the-key-prop-in-react-3ag7" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Understanding the importance of the key prop in React 🗝&lt;/h2&gt;
      &lt;h3&gt;Franco D'Alessio ・ Apr 1 '20&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#webdev&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#react&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/goals-project-l8xkl"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
    </item>
    <item>
      <title>React Series - 3 [State]</title>
      <dc:creator>Hermes</dc:creator>
      <pubDate>Tue, 12 Oct 2021 22:44:28 +0000</pubDate>
      <link>https://dev.to/truepadawan/react-series-3-state-men</link>
      <guid>https://dev.to/truepadawan/react-series-3-state-men</guid>
      <description>&lt;p&gt;State is an object in a component which holds some form of data relevant to the component it is created in.&lt;/p&gt;

&lt;p&gt;A State object is private to the component it is created in, It can be thought of as dynamic data managed by a component, unlike props which are just ‘static’ data that you pass into the component to render some form of information.&lt;/p&gt;

&lt;p&gt;Any modification to the value of a state object will cause the component instance it is created in to re-render itself to show the updated value.&lt;/p&gt;

&lt;p&gt;Originally 'states' were only usable in class-based component but with the addition of a new feature called 'Hooks' gave functional component the ability to use those extra features that class-based components had.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use States
&lt;/h3&gt;

&lt;p&gt;Lets look at a simple project to illustrate states. Visit this &lt;a href="https://codesandbox.io/s/states-example-j744g?file=/src/index.js"&gt;sandbox&lt;/a&gt;.&lt;br&gt;
It's just a simple interface for 'buying' a game.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8IHsD2J1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ymrwcihfypeajbzyevlh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8IHsD2J1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ymrwcihfypeajbzyevlh.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;import React,{ useState, useRef } from 'react';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In our component &lt;em&gt;GamePick&lt;/em&gt;, we import react along with &lt;em&gt;useState&lt;/em&gt; and &lt;em&gt;useRef&lt;/em&gt;, both of which are React Hooks.&lt;/p&gt;

&lt;p&gt;We also import the CSS file for our component.&lt;/p&gt;

&lt;p&gt;In functional components, a state is defined using the 'useState()' hook. It takes in the initial value of the state as its parameter and returns an array with two values; The value passed into it as a parameter and a function which can be used for updating the state object.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In functional components states can't be modified like normal variables, only through the use of the function that &lt;em&gt;useState&lt;/em&gt; returns.&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&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;purchaseOutput&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setPurchaseOutput&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;No purchases made.&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;priceVal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setPriceVal&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;currentProduct&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useRef&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the definition of our component, we create a state and using de-structuring; We pass it into a variable &lt;em&gt;purchaseOutput&lt;/em&gt;, and give also pass its updating function into variable &lt;em&gt;setPurchaseOutput&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Another state is also created which will handle prices of the products. We will like for the price in the input element to be changed when a different option is selected.&lt;/p&gt;

&lt;p&gt;We define a &lt;code&gt;ref&lt;/code&gt; object &lt;code&gt;currentProduct&lt;/code&gt; using the &lt;code&gt;useRef()&lt;/code&gt; hook. It is responsible for knowing what the current selected option is.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;useRef() essentially lets us define an object that exists throughout the lifetime of the component instance it is defined in. In this case, think of it as being similar to &lt;code&gt;useState&lt;/code&gt; except that when a &lt;code&gt;ref&lt;/code&gt; objects' value is updated/modified, it doesn't cause the component to re-render itself. The value of an object created using &lt;code&gt;useRef&lt;/code&gt; is accessed and modified using the &lt;code&gt;.current&lt;/code&gt; method not a function like states. A proper &lt;a href="https://www.react.express/hooks/useref"&gt;explanation&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Moving ahead to the JSX code, we have a simple select element along with a disabled input element and a button, all enclosed in divs' and given classes for styling. The states are put where they are needed in the JSX code.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;className&lt;/code&gt; is the equivalent of writing a normal class attribute in HTML&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In our select element, we listen for the &lt;code&gt;onChange&lt;/code&gt; event and call &lt;code&gt;selectHandler&lt;/code&gt; function when an option is picked.&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;selectHandler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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;setPriceVal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;event&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="nx"&gt;currentProduct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&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;In the &lt;code&gt;selectHandler&lt;/code&gt; function, we simply update the value of the &lt;code&gt;priceVal&lt;/code&gt; state (which is the value shown in the input element) and we update &lt;code&gt;currentProduct&lt;/code&gt; and set it's value to the current option selected.&lt;/p&gt;

&lt;p&gt;We also listen for an &lt;code&gt;onClick&lt;/code&gt; event on the button and call &lt;code&gt;buyHandler&lt;/code&gt; function when it is triggered.&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;buyHandler&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentProduct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;setPurchaseOutput&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;products&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;currentProduct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="s2"&gt; purchased for &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;prices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;currentProduct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="s2"&gt;.`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we're simply updating the &lt;code&gt;purchaseOutput&lt;/code&gt; state only if the option selected isn't the default value in the  element.&lt;/p&gt;

&lt;p&gt;Try out the app in the sandbox to understand the code better.&lt;/p&gt;

&lt;p&gt;Comment below if you didn't understand something properly and I will try to help you. Thanks for reading&lt;/p&gt;

</description>
      <category>react</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>React Series - #2 [Component &amp; Props]</title>
      <dc:creator>Hermes</dc:creator>
      <pubDate>Sun, 03 Oct 2021 22:48:27 +0000</pubDate>
      <link>https://dev.to/truepadawan/react-series-2-component-props-52pl</link>
      <guid>https://dev.to/truepadawan/react-series-2-component-props-52pl</guid>
      <description>&lt;h3&gt;React Component&lt;/h3&gt;

&lt;p&gt;A Component can seen as a core element of every React UI.&lt;/p&gt;

&lt;p&gt;A UI made with react is essentially a combination of multiple components, the components are defined once and can be re-used in multiple parts of the UI and through the use of the &lt;strong&gt;Props System&lt;/strong&gt; they can be dynamic.&lt;/p&gt;

&lt;p&gt;Components can either be defined through the use of functions or classes with the latter being used for complex components.
&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// FUNCTION SYNTAX&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&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="nx"&gt;Hello&lt;/span&gt; &lt;span class="nx"&gt;World&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;span class="c1"&gt;// CLASS SYNTAX&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="kd"&gt;extends&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;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;render&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="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="nx"&gt;Hello&lt;/span&gt; &lt;span class="nx"&gt;World&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;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A component defined using classes has to extend the React.Component class and define a &lt;code&gt;render&lt;/code&gt; method which specifies what exactly that component renders visually on the page.&lt;/p&gt;

&lt;h3&gt;Props System&lt;/h3&gt;

&lt;p&gt;React Components can accept input called props(properties) which allows for the same component displaying different information in the same format, just like how the return value of a function might be based on the arguments passed. Lets see what this looks like:&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;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&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="nx"&gt;Hello&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;props&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;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;render&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;App&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;Hermes&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#root&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 have added a bit dynamism to the App component, the name can be specified now. Now if we need to output 'Hello' statements for different names, we would just need to call the component with different names. This illustrates 'Re-usability' of components in react.&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;Hello&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&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="nx"&gt;Hello&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;props&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;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Hello&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;Hermes&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;Hello&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;Jack&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;Hello&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;Jill&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;/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;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;render&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;App&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#root&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;Another Example : &lt;a href="https://codepen.io/truepadawan/pen/BaZMBov"&gt;https://codepen.io/truepadawan/pen/BaZMBov&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading, drop a follow to find out when I drop the next in the series as I learn react.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/truepadawan/react-series-1-intro-2d95"&gt;Previous Article&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>beginners</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>React Series - #1 [ Intro ]</title>
      <dc:creator>Hermes</dc:creator>
      <pubDate>Thu, 30 Sep 2021 01:04:27 +0000</pubDate>
      <link>https://dev.to/truepadawan/react-series-1-intro-2d95</link>
      <guid>https://dev.to/truepadawan/react-series-1-intro-2d95</guid>
      <description>&lt;p&gt;I've decided to dive into React and will be making a blog-series on react as I learn it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Note: Take a look at&lt;/code&gt;&lt;a href="https://dev.to/hareom284/javascript-fundamentals-before-learning-react-1mkl"&gt;this&lt;/a&gt; &lt;code&gt;post first to get a feel of some JavaScript syntax that is used in React.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;React is a popular JavaScript library used mostly in building user-interfaces.&lt;/p&gt;

&lt;p&gt;Let's have a look at what a React application(not really an app) looks like:&lt;/p&gt;

&lt;p&gt;First, To setup a simple react-environment, make sure node-js is installed, then open the terminal and navigate(in-terminal) to a directory where you would like the react-project to be in then write this command in the terminal&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx create-react-app name-of-project&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;This will use a package "create-react-app"( used for generating react projects ) to generate a react project in a folder "name-of-project". It downloads the react library along with some other dependencies and useful tools, then sets up a template for a project.&lt;/p&gt;

&lt;p&gt;With the react environment successfully setup there should be a couple of folders like 'public, src, node_modules'.&lt;br&gt;
&lt;code&gt;public: holds static files like the html files&lt;/code&gt;&lt;br&gt;
&lt;code&gt;src: holds the react source code we're working on&lt;/code&gt;&lt;br&gt;
&lt;code&gt;node_modules: holds dependencies of the project&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Delete the files in 'src' folder and then create a fresh js file in there called 'index.js' and we can begin to code in React.&lt;/p&gt;

&lt;p&gt;Copy this code snippet into the js file :&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;import&lt;/span&gt; &lt;span class="nx"&gt;ReactDOM&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-dom&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="nx"&gt;App&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="nx"&gt;Hello&lt;/span&gt; &lt;span class="nx"&gt;World&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;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;render&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;App&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#root&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;First we're importing the react and react-dom library and assigning it to a variable "React" and "ReactDOM".&lt;br&gt;
&lt;code&gt;react-dom library allows react to interact with the DOM.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We define a React Component using arrow function syntax which returns what looks like a HTML div tag with the string "Hello World!" but in reality is just JSX (Javascript XML) which is used with React to describe what the UI should look like.&lt;/p&gt;

&lt;p&gt;JSX doesn't have to be used but it makes things better and more readable, the non-JSX equivalent of the code is:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;React.createElement("div", null, "Hello World!");&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;which might not look bad when we replace the JSX code with it, but when you start writing more complex code, it can potentially mess up the beauty of your code.&lt;/p&gt;

&lt;p&gt;Then we use the react-dom to render the react component we created inside a div with "id" of 'root'. The app component is wrapped in JSX syntax which is better than having to write something like &lt;code&gt;react.default.createElement(App, null)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Note : The HTML file that contains the div is in the 'public' folder&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Run &lt;code&gt;npm start&lt;/code&gt; in the react project folder to run your project, it will open the page in your browser.&lt;/p&gt;

&lt;p&gt;Thanks for reading this short blog, Drop a follow to be informed when I drop the continuation of this post&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>100daysofcode</category>
    </item>
    <item>
      <title>React Series - #1 [ Intro ]</title>
      <dc:creator>Hermes</dc:creator>
      <pubDate>Thu, 30 Sep 2021 00:23:51 +0000</pubDate>
      <link>https://dev.to/truepadawan/react-series-1-intro-40ga</link>
      <guid>https://dev.to/truepadawan/react-series-1-intro-40ga</guid>
      <description>&lt;p&gt;I've decided to dive into React and will be making a blog-series on react as I learn it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Note: Take a look at&lt;/code&gt;&lt;a href="https://dev.to/hareom284/javascript-fundamentals-before-learning-react-1mkl"&gt;this&lt;/a&gt; &lt;code&gt;post first to get a feel of some JavaScript syntax that is used in React.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;React is a popular JavaScript library used mostly in building user-interfaces.&lt;/p&gt;

&lt;p&gt;Let's have a look at what a React application(not really an app) looks like:&lt;/p&gt;

&lt;p&gt;First, To setup a simple react-environment, make sure node-js is installed, then open the terminal and navigate(in-terminal) to a directory where you would like the react-project to be in then write this command in the terminal&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx create-react-app name-of-project&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;This will use a package "create-react-app"( used for generating react projects ) to generate a react project in a folder "name-of-project". It downloads the react library along with some other dependencies and useful tools, then sets up a template for a project.&lt;/p&gt;

&lt;p&gt;With the react environment successfully setup there should be a couple of folders like 'public, src, node_modules'.&lt;br&gt;
&lt;code&gt;public: holds static files like the html files&lt;/code&gt;&lt;br&gt;
&lt;code&gt;src: holds the react source code we're working on&lt;/code&gt;&lt;br&gt;
&lt;code&gt;node_modules: holds dependencies of the project&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Delete the files in 'src' folder and then create a fresh js file in there called 'index.js' and we can begin to code in React.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>100daysofcode</category>
    </item>
    <item>
      <title>CS50x Final Project Update</title>
      <dc:creator>Hermes</dc:creator>
      <pubDate>Sat, 28 Aug 2021 12:00:53 +0000</pubDate>
      <link>https://dev.to/truepadawan/cs50x-final-project-update-1bi6</link>
      <guid>https://dev.to/truepadawan/cs50x-final-project-update-1bi6</guid>
      <description>&lt;h4&gt;My Project&lt;/h4&gt;

&lt;p&gt;I'm finally at the climax of the Harvard's CS50x course with only the Final Project remaining. I decided to do a News site using some of the new things I've learned in CS50x. I use the default HTML CSS Js for Front-end and Flask as my Back-end along with a News API gotten from newsapi.org&lt;/p&gt;

&lt;h4&gt;Progress&lt;/h4&gt;

&lt;p&gt;So far I've gotten a few things done which are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Register and Login Page with validation&lt;/li&gt;
&lt;li&gt;Database for storing user-data&lt;/li&gt;
&lt;li&gt;The main page which displays News gotten from the API&lt;/li&gt;
&lt;li&gt;Lazy-Loading: More news are loaded as the user scrolls to the bottom of the page&lt;/li&gt;
&lt;li&gt;Searching for specific news&lt;/li&gt;
&lt;li&gt;Filter out news by categories e.g Sports, Business, Tech&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J29-LISB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ludocx9nqkma87o5qk8t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J29-LISB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ludocx9nqkma87o5qk8t.png" alt="FrontPage of the Project"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hILqrRCU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/saf2v5kl1vlak8zq190j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hILqrRCU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/saf2v5kl1vlak8zq190j.png" alt="Searching for OnlyFans"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm currently thinking of removing the ability to create accounts because I can't think of a way to utilize it, I originally wanted it to be that the user can choose their interests and only get news based on that but now I'm not sure if it's even necessary to implement that. But I will try to implement the feature, if I can't then I will remove the ability to create an account.&lt;/p&gt;

</description>
      <category>cs50x</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>2021 CS50x - WEEK 9 UPDATE</title>
      <dc:creator>Hermes</dc:creator>
      <pubDate>Sun, 15 Aug 2021 11:37:40 +0000</pubDate>
      <link>https://dev.to/truepadawan/2021-cs50x-week-9-update-4kmh</link>
      <guid>https://dev.to/truepadawan/2021-cs50x-week-9-update-4kmh</guid>
      <description>&lt;p&gt;I just finished CS50X - Week 9 which is on Flask MicroFramework and I'm impressed with myself for reaching this far in the course, and hopefully I reach the end.&lt;/p&gt;

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

&lt;p&gt;CS50X - WEEK 9 teaches about Web Application using Flask, it teaches how data is passed and manipulated between client and server side in webpages. The lecture was very intuitive on the topic as usual.&lt;br&gt;
In the weeks' &lt;a href="https://cs50.harvard.edu/x/2021/psets/9/finance/"&gt;problem set&lt;/a&gt;, you were tasked with basically coding the backend and frontend of a website which allows users to trade stocks, the technologies used are SQL for storing user information, Python(Flask) for the backend, HTML|CSS for the webpages along with the use of Jinja Templating and also the &lt;a href="https://iexcloud.io"&gt;iexcloud.io&lt;/a&gt; API for getting information on stocks. You're provided with boilerplate code for just basic things and some helper functions to give you a foundation to build on with the end product looking similar to CS50x Staffs' &lt;a href="//finance.cs50.net"&gt;Solution&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;I recommend beginners like myself to take this course because it teaches a lot on different coding paths and its also free. You can register &lt;a href="https://learning.edx.org/course/course-v1:HarvardX+CS50+X/home"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm moving to week 10 now which is on Coding Ethics, I'm basically at the climax of the course and will start considering what I want to do for the Final Project.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Harvard's CS50X(Intro to Computer Science) is a free course that teaches the art of programming&lt;/code&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>html</category>
      <category>css</category>
      <category>flask</category>
    </item>
    <item>
      <title>2021 CS50x - WEEK 8 2nd Update</title>
      <dc:creator>Hermes</dc:creator>
      <pubDate>Wed, 04 Aug 2021 11:45:15 +0000</pubDate>
      <link>https://dev.to/truepadawan/2021-cs50x-week-8-2nd-update-4c6l</link>
      <guid>https://dev.to/truepadawan/2021-cs50x-week-8-2nd-update-4c6l</guid>
      <description>&lt;p&gt;Well I'm still in the problem set of Week 8 in Harvard's CS50x, this has been the longest I've spent on a problem(almost a week i think) in this course.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;RECAP: The problem set tasks you with using HTML, CSS, Js, Bootstrap to build a website about anything that interests you. You have to learn those technologies yourself and complete the task. This is my first time working with Web Dev so it's new territory for me.&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Specifications for the task:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P1lVAFm7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5gb158uimsq8a4insh2f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P1lVAFm7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5gb158uimsq8a4insh2f.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I just want to create something simple and at the same time fulfill the specifications they provided. So far I've used HTML, CSS, and Javascript. I think I've used Bootstrap when I turned a link into a button like this:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;a id="" class="btn btn-success" href="" target="_blank"&amp;gt;Text&amp;lt;/a&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;But my major problem is how to make the site look a particular way on mobile phones and computers of different screen size. So if you have any tips on how I could do that or even some Bootstrap tricks, drop a comment.&lt;/p&gt;

&lt;p&gt;I'm taking freeCodeCamp's Web Design course but it seems a bit long.&lt;/p&gt;

&lt;p&gt;Here's my progress so far with the page(Didn't even know what to do):&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KgENG0nw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hzgishcx92mq4vm9z8g9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KgENG0nw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hzgishcx92mq4vm9z8g9.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1e-blUvC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0x5ug9o12ge1rxd2qy83.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1e-blUvC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0x5ug9o12ge1rxd2qy83.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fzxzUclX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/acmvwomakvrh3nyso94x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fzxzUclX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/acmvwomakvrh3nyso94x.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7id8Bvva--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q34miuz1levh1i2nrq3g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7id8Bvva--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q34miuz1levh1i2nrq3g.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
Drop tips on how to make it look good on different screen sizes&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>html</category>
      <category>css</category>
      <category>javascript</category>
    </item>
    <item>
      <title>2021 CS50x - WEEK 8</title>
      <dc:creator>Hermes</dc:creator>
      <pubDate>Sat, 31 Jul 2021 11:03:49 +0000</pubDate>
      <link>https://dev.to/truepadawan/2021-cs50x-week-8-2fbh</link>
      <guid>https://dev.to/truepadawan/2021-cs50x-week-8-2fbh</guid>
      <description>&lt;p&gt;I've advanced to week 8 in Harvard's CS50x course which focuses on Web Development basically with HTML, CSS and JavaScript being the focus. The problem set for this week is to create a page using HTML,CSS,JavaScript and Bootstrap.&lt;/p&gt;

&lt;p&gt;So far in the lecture I learned a fair bit about Web Dev (I'm into Software Dev) but the problem is a bit challenging for me because I have no experience in HTML, CSS/Bootstrap and Js so I've got to start learning them, at least the basics which is what I'm doing using freeCodeCamp.&lt;br&gt;
But at the same time I'm also trying to see what I can do with my current little knowledge on HTML/CSS, the specifications for the problem set is a bit steep for me but I will definitely pull through(hopefully).&lt;/p&gt;

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

&lt;p&gt;So far what I've been able to create with my skillset is:&lt;/p&gt;

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

&lt;p&gt;I'm thinking of doing Khan Academy's HTML, CSS, Js lectures because I prefer video lectures to just texts on screen but so far I've been using freeCodeCamp and that's what I've been able to come up with, I still have a LOT to do and 3 more pages to create, not even done with the first, and I haven't used JavaScript or Bootstrap at all.&lt;/p&gt;

&lt;p&gt;I will drop an update in a few days when I improve my skills and do something better.&lt;/p&gt;

&lt;p&gt;Also please if you have any tips that can help, tell me in the comments.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>html</category>
      <category>css</category>
      <category>javascript</category>
    </item>
    <item>
      <title>CS50x 2021 - WEEK 7 (SQL)</title>
      <dc:creator>Hermes</dc:creator>
      <pubDate>Mon, 26 Jul 2021 19:32:31 +0000</pubDate>
      <link>https://dev.to/truepadawan/cs50x-2021-week-7-sql-350n</link>
      <guid>https://dev.to/truepadawan/cs50x-2021-week-7-sql-350n</guid>
      <description>&lt;p&gt;Finally completed CS50x Week 7 which deals with SQL....moving to Week 8 - HTML, CSS, JavaScript [Web Design]&lt;/p&gt;

&lt;p&gt;Week 7 focuses on the principle of SQL and Relational Databases, basically the basics of SQL (syntax and keywords) and how it differs with CSV files, also it's use case and advantages....Nice Lecture overall&lt;/p&gt;

&lt;p&gt;This week was the most impressive for me so far because the main problem &lt;a href="https://cs50.harvard.edu/x/2021/psets/7/fiftyville/"&gt;set&lt;/a&gt; really makes you understand how to use SQL..In the problem set - A thief has stolen an item and left the city, you're tasked to basically become the detective and find out the identity of the thief, accomplice and what city he fled to using a bunch of tables in a database.&lt;/p&gt;

&lt;p&gt;It's pretty confusing at first but if you have worked with SQL for a decent amount of time you'll probably find it easy but I've only used SQL few times when working with &lt;code&gt;Qt GUI Framework&lt;/code&gt;. But this problem set really improved my knowledge on it a bunch because you'll have to interact with the data of different tables at the same time and also think effectively how you would use them...Very impressive problem if you're a beginner.&lt;/p&gt;

&lt;p&gt;Gonna take a break before I move to HTML, CSS and JavaScript in WEEK 8. So far this course has been super impressive for a free course and I really advice beginners like myself to take it.&lt;/p&gt;

&lt;p&gt;Harvard's Intro to Computer Science (CS50x) is &lt;a href="https://learning.edx.org/course/course-v1:HarvardX+CS50+X/home"&gt;free&lt;/a&gt; to enroll in&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sY1n3kDB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7kv5kyml08ji6nrc128l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sY1n3kDB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7kv5kyml08ji6nrc128l.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>codenewbie</category>
      <category>beginners</category>
      <category>sql</category>
    </item>
    <item>
      <title>CS50x 2021 - WEEK 6 (PYTHON)</title>
      <dc:creator>Hermes</dc:creator>
      <pubDate>Sat, 24 Jul 2021 12:40:12 +0000</pubDate>
      <link>https://dev.to/truepadawan/cs50x-2021-week-6-python-on5</link>
      <guid>https://dev.to/truepadawan/cs50x-2021-week-6-python-on5</guid>
      <description>&lt;p&gt;Finally done with Week 6 of Harvard's CS50x course which was about &lt;code&gt;PYTHON&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It was basically a quick intro into python syntax and conversions of some programs we wrote in former weeks(in C) into python to teach how python works.&lt;/p&gt;

&lt;p&gt;It was very straightforward and simple to follow probably because the language is a lot easier to work with than C especially not needing to handle memory allocation and not defining what data type your variable is explicitly.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://cs50.harvard.edu/x/2021/psets/6/"&gt;problem&lt;/a&gt; set for Week 6 was to convert some of the previous problem sets we had done in C to Python...and another problem set called 'DNA' where we had to implement a program that identifies a person based on their DNA, It was pretty straightforward mostly except where you had to make a function that returns the longest consecutive repeats on a particular string in another larger string. I struggled writing that manually until i looked into &lt;code&gt;ReGex&lt;/code&gt; in python which made it very easy with just a few lines of code.&lt;/p&gt;

&lt;p&gt;It's nice to know about a new language, I will try to use it whenever I can like when doing LeetCode/HackerRank problems, I used C++ previously.&lt;/p&gt;

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

&lt;p&gt;Moving to Week 7 (SQL).&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>cs50</category>
      <category>python</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
