<?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: jpabloc17</title>
    <description>The latest articles on DEV Community by jpabloc17 (@jpabloc17).</description>
    <link>https://dev.to/jpabloc17</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%2F1123808%2F3b1d6ae1-0cea-479e-8f4d-e2beb3d5ae4a.png</url>
      <title>DEV Community: jpabloc17</title>
      <link>https://dev.to/jpabloc17</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jpabloc17"/>
    <language>en</language>
    <item>
      <title>"Props and States in React JS"</title>
      <dc:creator>jpabloc17</dc:creator>
      <pubDate>Sat, 07 Oct 2023 03:28:02 +0000</pubDate>
      <link>https://dev.to/jpabloc17/props-and-states-in-react-js-693</link>
      <guid>https://dev.to/jpabloc17/props-and-states-in-react-js-693</guid>
      <description>&lt;p&gt;React is a JavaScript library that we can use to build User Interfaces and separate the structure of the app into components. When working with React, we have different ways to pass data between parent and child components: &lt;strong&gt;Props and state.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a component?
&lt;/h2&gt;

&lt;p&gt;A component is basically a function that takes data (props) as an argument and returns JSX. Components are dynamic and enable us to think about each piece in isolation, helping us keep our code organized.&lt;/p&gt;

&lt;h2&gt;
  
  
  Props (Properties):
&lt;/h2&gt;

&lt;p&gt;Props are pieces of information passed from a parent component to a child component as objects that store the values of attributes of a tag. They can hold any kind of data, such as strings, numbers, objects, and even functions. They can be accessed in the child component as parameters of the component function.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--905jQxJw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dwqc4v6zpcwqhqnlyf0q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--905jQxJw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dwqc4v6zpcwqhqnlyf0q.png" alt="Image of porps" width="800" height="209"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  State:
&lt;/h2&gt;

&lt;p&gt;A state is essentially a variable used to contain information about the component that can change over the time as users interact with the application. State provides us with a way to maintain and update information within a component without requiring its parent to send the new information. The "change in the state" can happen as a response to user actions or system events. To use state, first, we need to import a hook from React called &lt;strong&gt;"useState&lt;/strong&gt;." The &lt;strong&gt;useState&lt;/strong&gt; hook will return an array with two variables inside of it: a reference to the current value and a set function so we can update that value."&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zQkLFz3---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/87gz2d8ed40pgetu8h6s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zQkLFz3---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/87gz2d8ed40pgetu8h6s.png" alt="Image of useState" width="578" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example, we have a Counter component that uses state to  Increment the value when the  button is clicked, the state changes, and the component re-renders every time the we updated count.&lt;/p&gt;

&lt;p&gt;In conclusion, props can pass data from parent to child components, while states can manage dynamic data within a component, allowing the user to update it while interacting.&lt;/p&gt;

</description>
      <category>react</category>
      <category>props</category>
      <category>hooks</category>
      <category>programming</category>
    </item>
    <item>
      <title>For Loop, Use &amp; Syntax</title>
      <dc:creator>jpabloc17</dc:creator>
      <pubDate>Sat, 22 Jul 2023 01:19:03 +0000</pubDate>
      <link>https://dev.to/jpabloc17/for-loop-use-syntax-11da</link>
      <guid>https://dev.to/jpabloc17/for-loop-use-syntax-11da</guid>
      <description>&lt;p&gt;Sometimes we find that we have to write the same code many times. For example, having to print the numbers from 1 to 100 on the console would be very tedious nor would it be very efficient.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RBaz00Mz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/is643h9j8bllvn9l32iz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RBaz00Mz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/is643h9j8bllvn9l32iz.png" alt="example of writing console.log() 100 times" width="312" height="211"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Here is when loops become handy:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Loops allow us to execute the same code a certain number of times. We can use a "&lt;strong&gt;for&lt;/strong&gt;" loop instead of writing a console.log() 100 times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For loop syntax:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The syntax consists of the keyword "&lt;strong&gt;for&lt;/strong&gt;" followed by parentheses and curly braces (&lt;strong&gt;for(){}&lt;/strong&gt;)&lt;/p&gt;

&lt;p&gt;Inside the braces we have the &lt;strong&gt;loop-body&lt;/strong&gt; which is the code to be executed. Inside the parentheses we have the number of times our code is going to be executed. This is made up of several parameters separated by semicolons "&lt;strong&gt;;&lt;/strong&gt;".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZOvIg9hb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vfmv5hgc09ism8f0eyc2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZOvIg9hb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vfmv5hgc09ism8f0eyc2.png" alt="For loop syntax" width="800" height="126"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Initialization:&lt;/strong&gt; This will be our starting point, here we can define a variable that will be used as our counter. &lt;strong&gt;Conts&lt;/strong&gt; should not be used since its value will be changing, typically the initial value is 0 or 1.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Condition:&lt;/strong&gt; Here we write the ending point. We must define how many times we want our code to be executed. This means that our loop will be executed while the condition is true. &lt;br&gt;
&lt;em&gt;It is important to have an ending point if we do not want our loop run an infinite number of times.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Iteration:&lt;/strong&gt; The iteration is what is executed at the end of each loop. Here we will define what we want to happen with our variable. For example, increase or decrease its value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Loop Body:&lt;/strong&gt; This will be the code to execute for each time while the condition is true.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eG27oO4J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8jevbomcp75jvxpuaq3g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eG27oO4J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8jevbomcp75jvxpuaq3g.png" alt="for loop example" width="589" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example we define our variable "&lt;strong&gt;i&lt;/strong&gt;" equal to &lt;strong&gt;1&lt;/strong&gt; since we want to print the numbers from 1 to 100. This would be our counter.&lt;/p&gt;

&lt;p&gt;The condition would be that as long as the value of our variable "&lt;strong&gt;i&lt;/strong&gt;" is less than or equal to 100, our loop will continue to execute.&lt;/p&gt;

&lt;p&gt;For the iteration, each time our code is executed, one will be added to "&lt;strong&gt;i&lt;/strong&gt;". In JS, we can do this using '&lt;strong&gt;++&lt;/strong&gt;'.&lt;/p&gt;

&lt;p&gt;For the body, we are using "&lt;strong&gt;i&lt;/strong&gt;" inside the parentheses to print its value after each cycle.&lt;/p&gt;

&lt;p&gt;As we can see using the "&lt;strong&gt;for&lt;/strong&gt;" loop, we can get the same result without having to write 100 separate "console.log()". Loops are powerful tools that help us simplify and improve our code.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>learning</category>
      <category>coding</category>
    </item>
  </channel>
</rss>
