<?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>Forem: sitoleslie</title>
    <description>The latest articles on Forem by sitoleslie (@sitoleslie).</description>
    <link>https://forem.com/sitoleslie</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%2F457258%2F7e2264cb-9b6c-4e08-9fc7-8e14b6a9b48d.jpeg</url>
      <title>Forem: sitoleslie</title>
      <link>https://forem.com/sitoleslie</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sitoleslie"/>
    <language>en</language>
    <item>
      <title>ReactJS components</title>
      <dc:creator>sitoleslie</dc:creator>
      <pubDate>Mon, 31 Aug 2020 01:35:12 +0000</pubDate>
      <link>https://forem.com/sitoleslie/reactjs-components-1jh4</link>
      <guid>https://forem.com/sitoleslie/reactjs-components-1jh4</guid>
      <description>&lt;p&gt;Hey,guys! Welcome to another week of my blogs! In this blog, I will be introducing you to React. What is React? React is the most popular front-end Javascript library for building user interfaces.If you want to bring more value to the table when applying for jobs having react on your resume is very important. But, first let's get you all set up then we can talk about components.&lt;/p&gt;

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

&lt;p&gt;Getting started. Create React App is a way to create a single-page application. First, we must set up our environment by running these commands below in your terminal:&lt;/p&gt;

&lt;p&gt;npx create-react-app new-app(name of your app)&lt;br&gt;
cd new-app&lt;br&gt;
npm start&lt;/p&gt;

&lt;p&gt;This will take a while to complete so be patient..&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ACRQ8UNR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fw2708l1b7fckly6uq9w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ACRQ8UNR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fw2708l1b7fckly6uq9w.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How it looks successfully: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F8HNPBHB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0iehm2ehka5jstwcnva3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F8HNPBHB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0iehm2ehka5jstwcnva3.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Last set up step:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iJkP8NtD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9mx1057jaebwtpah2n32.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iJkP8NtD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9mx1057jaebwtpah2n32.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, that we have gotten you all set up. Let's move on to the next point... Component is a section or part of the user interface. When creating with React we are using independent and isolated components to create complex user interfaces. User interface is what the user sees and interacts with. First, you will start with a root component. The root acts as a container for the whole application and has child components. &lt;/p&gt;

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

&lt;p&gt;In Javascript, the component is a class that will have a state and render method. The state will contain the displayed data when it is rendered. The render method will describe what the user interface will look like. Render has an output method that is a react element that reacts to a DOM element known as a plain object that holds the DOM element in memory. React is straight forward because we do not have to hard code in query by manipulating the DOM or attach event handlers to the DOM elements. This is done by changing the state component allowing React to update the DOM. In other words, React will react to state changes. &lt;/p&gt;

&lt;p&gt;Let's build our first component. First, under your src folder create another folder named components. All of your components will be located here. Then create a new file under the same folder and name it followed by .jsx. The jsx extension is better for code completion. Now, let's import the component class from the react module on the second line. Then create a class that will extend from the Component that we imported on the top from the React module. The component class will contained various amounts of methods that we are going to inherit for this class we created. &lt;/p&gt;

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

&lt;p&gt;In this example, we will only have the render method. Inside we will return an jsx expression which will get compiled to calls to React.createElement. Therefore, the react object on line 2 has to be imported regardless if the code will be used or not. Once the class is defined, it will be exported separately on line 10.  &lt;/p&gt;

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

&lt;p&gt;Now, in your index.js you must import your First component. Now, we are going to render our First component by extending the html vocabulary so wherever we have the First component we are also getting the output of that component that is determined by what is being returned in the render method. Therefore, in your browser you will see what is being render. &lt;/p&gt;

&lt;p&gt;Congrats, you just created your first component. (: &lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>firstyearincode</category>
    </item>
    <item>
      <title>The 'this' keyword</title>
      <dc:creator>sitoleslie</dc:creator>
      <pubDate>Mon, 24 Aug 2020 00:35:16 +0000</pubDate>
      <link>https://forem.com/sitoleslie/the-this-keyword-417o</link>
      <guid>https://forem.com/sitoleslie/the-this-keyword-417o</guid>
      <description>&lt;p&gt;In this post, we will take a dive into the keyword "this". It can be very confusing at first, but once we take a closer look you will see how simple it is. What is "this"? It will always reference the object that it is executing the current function. Okay? So exactly what object ? Well, it will be determined when the function gets invoked. There are five different invocations: Global reference, Free function, .call/.apply, construction mode, and method. Also, in Javascript functions are objects which is the reasoning for using dot notation. You will see that I avoided using arrow functions. When you do be careful, because arrow function inherit the "this" value for the containing function,&lt;/p&gt;

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

&lt;p&gt;Here..we go..are you ready? First, Global Reference is the global object that is in the window inside the browser and global in node. So, "this" by itself, variables using the keyword var, and regular function will reference to the global object. In the snippet below google chrome developer is used. &lt;/p&gt;

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

&lt;p&gt;You got "this", because next up is...Free function invocation. The binding target is the global object (window in the browser but global in node, duh). I mean.. it's not really useful but it was picked as a binding for 'this'. Since, the function is being called freely, it is a Free function invocation.&lt;/p&gt;

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

&lt;p&gt;A very simple rule is if the function is part of an object, it is known as method invocation. The "this" will reference that object itself. The binding target is the object on the left of the call time dot. In the example below, an object was declared and assigned to city with two properties: a string variable and method. When the food method in the city object is being called, it will reference the object itself. In conclusion, always remember "this" will reference to the object on the left of the calling dot. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OFTfQZRl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vpvv7dxjokxeubcro41b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OFTfQZRl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vpvv7dxjokxeubcro41b.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hgS9ifYl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/90iargvxkl4yzapgfxos.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hgS9ifYl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/90iargvxkl4yzapgfxos.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, we are getting to the fun part. What if we need "this" to reference another object instead of the one it is in? Good question! Well the answer to all your problems is .call or .apply innovation. The .call method calls a method on an object, replaces with another object for the current one. While .apply method calls the function, replaces the object for the "this" value of the function. The binding target is the first argument to .call or .apply. These invocation will invoke a function immediately and change the "this" original object reference to the desired one. They both get the same job done, however .apply handles an array as an argument. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MhsWfyF2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/us6p6w49o3nxwl1tj982.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MhsWfyF2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/us6p6w49o3nxwl1tj982.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lZr8ST_e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/619u3kjlybmw8bfa1im7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lZr8ST_e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/619u3kjlybmw8bfa1im7.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Did I lose you, yet? Geez..I hope not because this is the last one, Constructor function. The constructor function can be called by using the new operator. The binding target is the new object created. A constructor function will be declared by using Pascal Case for the name of the class. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oR6ykfDc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3uk3eg1mtnjl1e1k9c27.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oR6ykfDc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3uk3eg1mtnjl1e1k9c27.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--z26uTluc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pyqzcpjcrpq91g1qtosy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--z26uTluc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pyqzcpjcrpq91g1qtosy.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is my last "you got this"... I swear. &lt;/p&gt;

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

&lt;p&gt;Thanks for reading my very first blog! I am an immersion junior student at Operation Sparks. I hope that you found this read very helpful and educating. Because, at first I was very confused about the key word "this". I would guess where the "this" object was referencing too. Bad practice, right? Worry no more, because this blog got you! &lt;/p&gt;

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