<?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: Isabelle Bessa</title>
    <description>The latest articles on DEV Community by Isabelle Bessa (@isabessa05).</description>
    <link>https://dev.to/isabessa05</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%2F904371%2F9893ccdf-45e1-488f-bdec-de0465bccce0.jpeg</url>
      <title>DEV Community: Isabelle Bessa</title>
      <link>https://dev.to/isabessa05</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/isabessa05"/>
    <language>en</language>
    <item>
      <title>useContext clues!</title>
      <dc:creator>Isabelle Bessa</dc:creator>
      <pubDate>Wed, 16 Nov 2022 01:07:09 +0000</pubDate>
      <link>https://dev.to/isabessa05/usecontext-clues-3iem</link>
      <guid>https://dev.to/isabessa05/usecontext-clues-3iem</guid>
      <description>&lt;p&gt;During my time at Flatiron School, one of my favorites learning experiences was working with React. I found it to be a very fun and easy library to work with, specially with the use of props and states.&lt;/p&gt;

&lt;p&gt;But as most fun things do, it worn down. By the time I was passing my props through 12 different components to get to my final one where I would finally be able to get usage out of it, thing became heated. I might or might not have cursed a little (no bad feelings, React. You're still my favorite).&lt;/p&gt;

&lt;p&gt;As a result, I got the thought that comes at least once a day to every software engineer: &lt;/p&gt;

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

&lt;p&gt;And there is! useContext is a simple React Hook that allows you to send values down different called components and even change them along the road.&lt;/p&gt;

&lt;p&gt;According to its documentation, useContext accepts a context object (the value returned from React.createContext) and returns the current context value for that context. The current context value is determined by the value prop of the nearest  above the calling component in the tree.&lt;/p&gt;

&lt;p&gt;I'm gonna show you how to use this Hook in three steps. Let's build a boyfriend rater!&lt;/p&gt;

&lt;p&gt;I did the hard work for you, so here's what our app looks like now:&lt;/p&gt;

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

&lt;p&gt;Say I want to add some information to my card, a message that is currently in my App.js. I could pass it as a prop, but I also want to change that message with a onClick function. That's when we use useContext.&lt;/p&gt;

&lt;p&gt;First, we have to create a new component and define the context. Then, this is the code we will use inside the component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { createContext } from 'react';

const MessageContext = createContext(null)

export default MessageContext;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now inside our App component, we are gonna import that component and call it inside our return, between the components that will use it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import MessageContext from './MessageContext'

  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;MessageContext&amp;gt;
      &amp;lt;h1&amp;gt; Rate your Boyfried&amp;lt;/h1&amp;gt;
     &amp;lt;BfCard/&amp;gt;
     &amp;lt;/MessageContext&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;

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

&lt;/div&gt;



&lt;p&gt;To send a value down the components, we still need to add the .Provider and value to the context. The value will be whatever we want to to make accessible for other components. In this case, our value will be our message.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import MessageContext from './MessageContext'

const [message, setMessage] = useState(false)

  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;MessageContext.Provider value={{message, setMessage}}&amp;gt;
      &amp;lt;h1&amp;gt; Rate your Boyfried &amp;lt;/h1&amp;gt;
     &amp;lt;BfCard/&amp;gt;
     &amp;lt;/MessageContext.Provider&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;

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

&lt;/div&gt;



&lt;p&gt;Note that we are also sending down our setMessage inside value. That will allow us to change the contents of message and update our state when changing the message by onClick. Extra note for the ending tab of MessageContext that must also include .provider. Don't forget or you might find yourself debugging errors for hours simply because of it. I don't speak from personal experience. &lt;/p&gt;

&lt;p&gt;Now inside BFCard, we need to add a little more code to be able to call the message. We have to import the MessageContext component, and call it inside a variable with useContext. Like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//import useContext
import {useContext} from 'react'
import MessageContext from './MessageContext'

//set the variable as you would set state, but inside curly brackets and with useContext instead of useState

const {message, setMessage } = useContext(MessageContext)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Well done! Now you can use and change your message value whenever you need. This was a simple use of the useContext hook, mostly to demonstrate how easy and simple it is. In more complex apps, you can use it to send user information, data from fetches and much more. Don't let the props stop you into your quest to become a great developer. Happy coding!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Rails likes validation - and who doesn't?</title>
      <dc:creator>Isabelle Bessa</dc:creator>
      <pubDate>Mon, 24 Oct 2022 18:05:44 +0000</pubDate>
      <link>https://dev.to/isabessa05/rails-likes-validation-and-who-doesnt-1c89</link>
      <guid>https://dev.to/isabessa05/rails-likes-validation-and-who-doesnt-1c89</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T0MSG2-5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vq5jxtv4zclol163985s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T0MSG2-5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vq5jxtv4zclol163985s.png" alt="Image description" width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ruby on Rails is a great framework and with Active Record, its uses are almost endless. By using two or three lines of command, you can create a complete MVC program that amounts for many different uses. You can build everything from a blog platform to a dog party planning website (which if you do, please share it with me).&lt;/p&gt;

&lt;p&gt;The only issue would be controlling your client-side. We all know clients are wild, and the internet is full of trolls. How do we make sure our program is being used for its full purpose? Or at least receiving the right information?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://guides.rubyonrails.org/active_record_validations.html#validations-overview"&gt;Validation&lt;/a&gt; comes in hand for that. Validations are used to ensure that only valid data is saved into your database. They are database agnostic, cannot be bypassed by end users, and are convenient to test and maintain.&lt;/p&gt;

&lt;p&gt;You can be very specific in your validations, provided that rails give us a generous amount of validation helpers. The most common ones are acceptance, length, presence, numericality and uniqueness. In this post we are gonna be showing how to use those examples, but don't restrain yourself!&lt;/p&gt;

&lt;h2&gt;
  
  
  Example: blog plataform
&lt;/h2&gt;

&lt;p&gt;Imagine you're building a short blog platform (like Twitter), and you need to make sure every user is following the rules for blog posts, tags and title. This is what our post model looks like now:&lt;br&gt;
&lt;/p&gt;

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

class Post &amp;lt; ApplicationRecord
belongs_to :user

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

&lt;/div&gt;



&lt;p&gt;Pretty empty, but we will change that soon. We add all of our validations to our model componente. We want to make sure that every post has a content, at least one tag and a title. Let's validate the presence of those:&lt;br&gt;
&lt;/p&gt;

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

class Post &amp;lt; ApplicationRecord
belongs_to :user

validates :content, :tags:, :title, presence:true

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

&lt;/div&gt;



&lt;p&gt;validates :element is our syntax for validations. Adding presence validates that the specified attributes are not empty.&lt;/p&gt;

&lt;p&gt;Great, now we can't create a post without a content, a tag and a title. But we also don't want blog posts or titles that are just a single word. Let's add a Length helper to that:&lt;br&gt;
&lt;/p&gt;

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

class Post &amp;lt; ApplicationRecord
belongs_to :user

validates :content, :tags:, :title, presence:true
validates :content, :title, length {in: 20..}

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

&lt;/div&gt;



&lt;p&gt;This helper validates the length of the attributes' values. Length also has many attributes that can be use to constrain the element in different ways (ex: {minimum:},{maximum:},{in: (range)}, {is:}.&lt;/p&gt;

&lt;p&gt;While adding tags during our test, we see that the same tag can be add an infinity number of times. That's not right! We want to make sure that every tag can only be added one time into each post. Let's use our uniqueness helper for that.&lt;br&gt;
&lt;/p&gt;

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

class Post &amp;lt; ApplicationRecord
belongs_to :user

validates :content, :tags:, :title, presence:true
validates :content, :title, length {in: 20..}
validates :tags, uniqueness: true

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

&lt;/div&gt;



&lt;p&gt;Validations help us control the information sent and received to our database. Along with &lt;a href="https://api.rubyonrails.org/classes/ActiveModel/Errors.html"&gt;error messages&lt;/a&gt;, they're also very useful to guide the user with application usage. You can explore more of it with the rails documentation, which is very extend. I hope this post helped you with it, and happy coding!!!!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Ruby and it's many, many (many) methods.</title>
      <dc:creator>Isabelle Bessa</dc:creator>
      <pubDate>Tue, 04 Oct 2022 13:12:30 +0000</pubDate>
      <link>https://dev.to/isabessa05/ruby-and-its-many-many-many-methods-4jmo</link>
      <guid>https://dev.to/isabessa05/ruby-and-its-many-many-many-methods-4jmo</guid>
      <description>&lt;p&gt;When told that Ruby was an Object Oriented Programming language, my first thought was: and? What is it that ruby can do that JavaScript (and React.js &amp;lt;3) can't?&lt;/p&gt;

&lt;p&gt;The answer to that is nothing. There's nothing ruby can do that can't be recreated with JS (well, except deal with &lt;a href="https://www.educba.com/javascript-vs-ruby/" rel="noopener noreferrer"&gt;high CPU intensive application development&lt;/a&gt;, but that's for another blog post). The main thing is: It can do it in a faster and simpler way than JS would ever think of doing it.&lt;/p&gt;

&lt;p&gt;And how is that possible? you may ask. Ruby has a lot of methods, which are a set of expressions that return a value. With it, it's easier to access and modify your code along the needs of your project. We won't be covering all of them here, because there would not be enough space. Instead, let's just go over the basics.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ywj8hbo1fx06y0ucheo.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%2F9ywj8hbo1fx06y0ucheo.gif" alt="Eleanor gets it"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  .first
&lt;/h3&gt;

&lt;p&gt;You know how when calling elements out from an array, you have to do the whole index thing? Array[0], or Array.obj[1], and it gets progressively worse? Ruby solved that for you. All you need to do is literally call the first element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array = [1,2,3,4,5]
array.first
=&amp;gt; 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What if I want the second element?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array = [1,2,3,4,5]
array.second
=&amp;gt; 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But that can't work for all of the elements. Can it?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array = [1,2,3,4,5]
array.third
=&amp;gt; 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;It can!!!!!!!!!!! *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fel8kuc1z0stnqgiuob4q.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%2Fel8kuc1z0stnqgiuob4q.gif" alt="We must stan"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  .include?
&lt;/h3&gt;

&lt;p&gt;That one sounds simple enough. We want to check if our element is included in the array we're searching through.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array = [1, 2, 3, 4, 5]
=&amp;gt; [1, 2, 3, 4, 5]
array.include?(3)
=&amp;gt; true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  .join
&lt;/h3&gt;

&lt;p&gt;This one is my pride and joy(n). You can call an array and transform it into a string, with a separator parameter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array.join
=&amp;gt; "1234"
array.join("*")
=&amp;gt; "1*2*3*4"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  .uniq
&lt;/h3&gt;

&lt;p&gt;As the name says, this iterates over an array and returns only one of each element that's in it. All the duplicate elements are removed from the array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array = [1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 6, 7, 8]
array.uniq
=&amp;gt; [1, 2, 3, 4, 5, 6, 7, 8]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  .drop_while
&lt;/h3&gt;

&lt;p&gt;It's a simpler way to select elements in your array. It drops elements up to, but not including, the first element for which the block returns nil or false and returns an array containing the remaining elements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = [1, 2, 3, 4, 5, 0]

a.drop_while { |i| i &amp;lt; 3 }   
=&amp;gt; [3, 4, 5, 0]

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

&lt;/div&gt;



&lt;p&gt;Now that you've seen how easy and intuitive ruby methods are, are you interested in learning more of them? Try it out and happy coding!&lt;/p&gt;

&lt;p&gt;Sources&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.freecodecamp.org/news/common-array-methods-in-ruby/" rel="noopener noreferrer"&gt;https://www.freecodecamp.org/news/common-array-methods-in-ruby/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidock.com/ruby" rel="noopener noreferrer"&gt;https://apidock.com/ruby&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Why you should use components when building your React.app</title>
      <dc:creator>Isabelle Bessa</dc:creator>
      <pubDate>Mon, 12 Sep 2022 15:04:04 +0000</pubDate>
      <link>https://dev.to/isabessa05/why-you-should-use-componentes-when-building-your-reactapp-3oc2</link>
      <guid>https://dev.to/isabessa05/why-you-should-use-componentes-when-building-your-reactapp-3oc2</guid>
      <description>&lt;p&gt;React is a lifesaver. Being the number one library used to create interactive UI's, it helps developers build applications faster and with more complex data.&lt;/p&gt;

&lt;p&gt;While learning React, I was amazed by the JSX and how the mix of HTML and JS worked to make life easier while coding. That's until I got to components.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are components?
&lt;/h2&gt;

&lt;p&gt;Let's imagine React as a big painting. You want to show the final result, but you also have to realize how many divisions are in it and how you have to work on them separately. Make a sketch, final draw, coloring, shading, and finally framing it. That's what components are in React; A division that allows you to split your code into independent and reusable pieces, and to work in each piece in isolation.&lt;/p&gt;

&lt;p&gt;Now that you know what components are, we should put it in practice! Let's build a simple React App using some components. &lt;/p&gt;

&lt;p&gt;If you don't know how to start your React.App, I suggest you follow the steps in &lt;a href="https://create-react-app.dev/docs/getting-started/"&gt;this react doc&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Great! Let's look into our src folder and see what's in there.&lt;/p&gt;

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

&lt;p&gt;Those are some of our components! We so far only have two: App.js and Index.js to which App is called. In this post, we will be creating two more: A header componente and a body component. You can name your components however you want, this is just an example.&lt;/p&gt;

&lt;p&gt;This is the code for our header component (You can delete whatever code between return in App and add the follow)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;div className="App"&amp;gt;
      &amp;lt;header className="App-header"&amp;gt;
        &amp;lt;h1&amp;gt;Hello!&amp;lt;/h1&amp;gt;
        &amp;lt;h2&amp;gt;This is a lesson about components&amp;lt;/h2&amp;gt;
      &amp;lt;/header&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now this is what our page is gonna look like:&lt;/p&gt;

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

&lt;p&gt;Now let's build our body&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
        &amp;lt;p&amp;gt;In this blog post, you gonna learn the importance of React components&amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;Some of those are:&amp;lt;/p&amp;gt;
        &amp;lt;ul&amp;gt;
          &amp;lt;li&amp;gt;Writing easy debugging code&amp;lt;/li&amp;gt;
          &amp;lt;li&amp;gt;Create independent bits of code&amp;lt;/li&amp;gt;
          &amp;lt;li&amp;gt;Make it simpler to work it more complex data&amp;lt;/li&amp;gt;
        &amp;lt;/ul&amp;gt;
      &amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This bit of code will look like this: &lt;/p&gt;

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

&lt;p&gt;Okay... this seems to work just fine, but our code is pretty simple. If you're working with more complex data, you'll have so many lines of code that it will be extremely hard to see in case you make even a simple syntax error. To save us from that, let's create our components.&lt;/p&gt;

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

&lt;p&gt;Now, we can transfer our code from both those elements directly to the components.&lt;/p&gt;

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

&lt;p&gt;Analyzing what we did there, we can see there are a few rules to follow while writing components:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You must always import React before writing the code;&lt;/li&gt;
&lt;li&gt;Write your code inside a function with a return, otherwise your code won't be passed to the parent component;&lt;/li&gt;
&lt;li&gt;Your function MUST start with capital letter. I know, in vanilla JavaScript you're not supposed to use capital letters to start names, but that's a React rule. Don't forget!&lt;/li&gt;
&lt;li&gt;And at last, remember to export your component!&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Why export my function?
&lt;/h2&gt;

&lt;p&gt;That will allow your other components to use that component in them. If you don't export, you won't be able to import it inside the other elements.&lt;/p&gt;

&lt;p&gt;Let's see how those components will look inside our App component.&lt;/p&gt;

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

&lt;p&gt;Reloading your browser, you will see that the layout is the same as when we wrote the code directly into App. But now you have access to that code separately, and it's easier for you to work on and build more intricate apps. &lt;/p&gt;

&lt;p&gt;Have fun working with your components!&lt;/p&gt;

&lt;p&gt;Sources:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/docs/components-and-props.html"&gt;Components - React Docs&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/reactjs-components/"&gt;React JS Components - Geeks for Geeks&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/folajomi__/building-react-components-i-functional-components-3di4"&gt;Building React Components - DEV &lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>components</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How console.log might save your code from yourself</title>
      <dc:creator>Isabelle Bessa</dc:creator>
      <pubDate>Mon, 22 Aug 2022 23:57:00 +0000</pubDate>
      <link>https://dev.to/isabessa05/how-consolelog-might-save-your-code-from-yourself-141p</link>
      <guid>https://dev.to/isabessa05/how-consolelog-might-save-your-code-from-yourself-141p</guid>
      <description>&lt;p&gt;Starting my bootcamp, there were two things I knew about javascript:&lt;/p&gt;

&lt;p&gt;1.Using a ";" to separate code lines is optional, but helps your code;&lt;br&gt;
2.Console.log EVERYTHING.&lt;/p&gt;

&lt;p&gt;As a great know-it-all, I refused to follow both rules. That got me stuck in many different situations, but what really opened my eyes to the importance of console.log was failing my first code challenge.&lt;/p&gt;

&lt;p&gt;And here's how I'm gonna save you from the same mistake.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is console.log()?
&lt;/h2&gt;

&lt;p&gt;In simple words, console.log() outputs to your console whatever you request it to.If you're familiar with other languages, such as python, you probably know it as print().&lt;/p&gt;
&lt;h2&gt;
  
  
  What parameters does it take?
&lt;/h2&gt;

&lt;p&gt;console.log() takes any parameter. It can be used for strings, arrays, objects, and to access HTML content by JavaScript. On a side note, console.log() outputs the value you're looking for regarding the moment you open your console.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why do I need to use it?
&lt;/h2&gt;

&lt;p&gt;Let's start with a simple example. We're trying to update our website so it shows the first object of our json file. We want it to show the image, name and description of our product.&lt;/p&gt;



&lt;p&gt;For that, we're creating a function that assigns our values from the json file to our html content, like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//setting the element information 
function setElementInfo (element){

    //display the element name 
    const elementName = document.getElementById("detail-title");

    //display the element image
    const elementImage = document.getElementById("detail-image");


    elementName.textContent = element.name;
    elementImage.src = element.image;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Okay, that looks great! Let's try calling this function by the data we got from out fetch request.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//requesting the information from the json file
fetch("http://localhost:3000/data")
//returning the response from the file and reading it to javascript
.then(response =&amp;gt; response.json())
.then(data =&amp;gt; {

    setElementInfo(data)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's update our HTML page and see how this works!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zET3oCbt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wkumnths1algojihxv37.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zET3oCbt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wkumnths1algojihxv37.png" alt="Our console log in the HTML browser" width="880" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Oh, no. We got an error there, and it says it can't find our data. That's weird. It's a very open error and it doesn't show in what line we made a mistake or what exactly is the problem with our code. How can we find out more about it?&lt;/p&gt;

&lt;h2&gt;
  
  
  Enter console.log()
&lt;/h2&gt;

&lt;p&gt;For staters, let's make sure we have our return data right, by logging it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//requesting the information from the json file
fetch("http://localhost:3000/data")
//returning the response from the file and reading it to javascript
.then(response =&amp;gt; response.json())
.then(data =&amp;gt; {
    console.log(data)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's reload our HTML browser and see what the console shows us.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--f4RZg4Ds--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5z1xk4512ysc6boxxmh3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--f4RZg4Ds--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5z1xk4512ysc6boxxmh3.png" alt="Our console log in the HTML browser" width="880" height="458"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Great, we go out data! But wait, it all comes in an array. We need to set only the first element of our array to show up, and how can we do that? Let's try calling it with our index.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//requesting the information from the json file
fetch("http://localhost:3000/data")
//returning the response from the file and reading it to javascript
.then(response =&amp;gt; response.json())
.then(data =&amp;gt; {

    setElementInfo(data[0])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, reloading our HTML page.&lt;/p&gt;

&lt;p&gt;Great! We got our first element to show when our page loads. Thanks, console.log()!&lt;/p&gt;

&lt;h2&gt;
  
  
  What to take from this?
&lt;/h2&gt;

&lt;p&gt;When working with too many elements and functions, specially while building websites, it's easy to get our data confused. What we think it might be a string turns out to be an array, or our calls to html function sometimes return whole html objects, instead of a simple value inside that object. &lt;/p&gt;

&lt;p&gt;console.log() helps your access your data and what you are building into your code to help you make less errors, and have less frustrations while working on a big program. It's easier to console.log() every data and variable as it is set, than face an error while running the code and having to checking everything from the beginning.&lt;/p&gt;

&lt;p&gt;I hope this post helped you understand the importance of console.log() while creating your code and how it can help you improve your programming!&lt;/p&gt;

&lt;p&gt;Sources:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Console/log"&gt;console.log() - Web APIs - MDN &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=WPAW6agH1lo"&gt;What is console.log in JavaScript?&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
