<?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: Steven Dawn</title>
    <description>The latest articles on Forem by Steven Dawn (@sdwn).</description>
    <link>https://forem.com/sdwn</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%2F870717%2F5155c932-4ffb-41e3-9431-efe4e773d0a6.gif</url>
      <title>Forem: Steven Dawn</title>
      <link>https://forem.com/sdwn</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sdwn"/>
    <language>en</language>
    <item>
      <title>How to Configure your New Rails API to Use PostgreSQL</title>
      <dc:creator>Steven Dawn</dc:creator>
      <pubDate>Mon, 19 Sep 2022 04:07:13 +0000</pubDate>
      <link>https://forem.com/sdwn/how-to-configure-your-new-rails-api-to-use-postgresql-2c6f</link>
      <guid>https://forem.com/sdwn/how-to-configure-your-new-rails-api-to-use-postgresql-2c6f</guid>
      <description>&lt;h2&gt;
  
  
  Create a new Rails API and configure it to use PostgreSQL
&lt;/h2&gt;

&lt;p&gt;Since learning Ruby, Ruby on Rails and PostgreSQL I recently learned that Rails will default to other SQL variants installed on my machine first like SQLite which I used in a recent project before moving on to PostgreSQL. &lt;/p&gt;

&lt;p&gt;I'm sure I'm not the only one out there who didn't make sure that their Rails database wasn't configured to use Postgres automatically so I did some digging around to make this post to show you how to just that in 2 easy steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1
&lt;/h2&gt;

&lt;p&gt;Make your project folder and &lt;code&gt;cd&lt;/code&gt; into it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir example-app
cd example-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2
&lt;/h2&gt;

&lt;p&gt;Create the Rails backend with a PostgreSQL database using this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rails new my-example-app --api --database=postgresql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Bonus
&lt;/h2&gt;

&lt;p&gt;After &lt;code&gt;cd&lt;/code&gt;ing and running &lt;code&gt;bundle install&lt;/code&gt; in your new rails folder you're free to set up things like git if you want your work all in one repo. You can set up your React frontend in a subfolder with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --prefix client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you will never have the issue of wondering if you're using anything other than PostgreSQL for your Rails app! However the real work of actually building the Rails app has just begun but you can pat yourself on the back for getting this task done.&lt;/p&gt;

</description>
      <category>rails</category>
      <category>postgres</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A Break Down of Full-Stack Web Development</title>
      <dc:creator>Steven Dawn</dc:creator>
      <pubDate>Mon, 29 Aug 2022 23:27:00 +0000</pubDate>
      <link>https://forem.com/sdwn/a-break-down-of-full-stack-development-216c</link>
      <guid>https://forem.com/sdwn/a-break-down-of-full-stack-development-216c</guid>
      <description>&lt;h2&gt;
  
  
  If you asked me to sum up Full-Stack Web Development in one picture, it would be this:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8kFzQExt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nuqiv6e4gamxdcxirk7k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8kFzQExt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nuqiv6e4gamxdcxirk7k.png" alt="full stack dev meme" width="880" height="879"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Full-Stack Development&lt;/strong&gt; is someone who works with &lt;em&gt;both&lt;/em&gt; the front end and back end of a web application. The front end is used for look and feel of the website while the back end is responsible for logic and infrastructure of the website.&lt;/p&gt;

&lt;p&gt;This role is usually split between Front-End Developer and Back-End Developer. What are these things you ask?&lt;/p&gt;

&lt;p&gt;A Front-End Developer is someone who: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Works on the look and feel of the application they're working on&lt;/li&gt;
&lt;li&gt;Making sure requests are properly being sent to the backend&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A Back-End Developer is someone who: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creates and manages the database&lt;/li&gt;
&lt;li&gt;Create responses that will be used for the front-end&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As a Full-Stack developer, we will need to do a mix of &lt;em&gt;both&lt;/em&gt; of these tasks whether to make sure the application we're working on is functional.&lt;/p&gt;

&lt;p&gt;Here's an example of how an application we build would be handled: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Users visit our applications front-end, and will do some form of action, for example, try to log in or create an account.&lt;/li&gt;
&lt;li&gt;When they hit submit to sign up, a POST request containing data from our sign up form on the front-end is sent from our front-end to our API endpoint in the back-end server that is running.&lt;/li&gt;
&lt;li&gt;The back-end will receive the POST request at it's specific endpoint, and execute the action to create a new user in the database with the passed in data.&lt;/li&gt;
&lt;li&gt;If everything goes well, then the user interacting with the front-end will be redirected to the login page to log in with their newly created account.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Some skills you would need to create a full-stack application
&lt;/h2&gt;

&lt;p&gt;Of course these are not &lt;em&gt;all&lt;/em&gt; the skills/languages you need but knowing some or at least one part of the full-stack would be awesome!  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Front-End&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTML/CSS/JavaScript

&lt;ul&gt;
&lt;li&gt;HTML serves as the structure of our site, CSS is used to control the presentation and JavaScript is used to control the behavior of the different elements of our website&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;How to make HTTP requests to our back-end

&lt;ul&gt;
&lt;li&gt; This is how front-end devs interact with our back-end to display our data&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Learn a Framework

&lt;ul&gt;
&lt;li&gt;JavaScript frameworks like React, Angular or Next.js will take our web dev skills to the next level allowing us to easily build our applications to scale&lt;/li&gt;
&lt;li&gt;It is required that you have a solid grasp on JavaScript first before trying these frameworks out.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Wire-framing

&lt;ul&gt;
&lt;li&gt;This basically means drawing your website out before even starting to code&lt;/li&gt;
&lt;li&gt;There are tools like Figma that we use to achieve this but using pen and paper as a start is perfectly fine too&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Back-End&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Learn a back-end language Ruby on Rails, Python or JavaScript with the Express.js framework

&lt;ul&gt;
&lt;li&gt;This how we would write the back-end logic&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Learn SQL 

&lt;ul&gt;
&lt;li&gt;This is how we would create/manage our database&lt;/li&gt;
&lt;li&gt;Any SQL is fine but I recommend starting with SQLite since I think its beginner-friendly compared to PostgreSQL but the latter is more common in the workplace&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Data Structures and Algorithms

&lt;ul&gt;
&lt;li&gt; Knowing how to efficiently manage, search and sort through our data is key to becoming a great back-end dev&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Learn the MVC

&lt;ul&gt;
&lt;li&gt;Knowing MVC (Model View Controller) patterns comes in handy when creating the logic in our back end that responds to HTTP requests, and dictates what logic should be executed upon receiving a request&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Learn OOP

&lt;ul&gt;
&lt;li&gt;OOP (Object Oriented Programming) is useful for us define our database models and allows for abstractions with concepts like Classes and Inheritance&lt;/li&gt;
&lt;li&gt;OOP can also be applied in JavaScript/the front-end&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pMJycmF9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pjaa4vk82xmkhvzuzlqp.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pMJycmF9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pjaa4vk82xmkhvzuzlqp.jpeg" alt="full stack is hard" width="640" height="640"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Going down the full-stack path is a lot of work since even understanding either end of development is difficult with their own rabbit-holes but not impossible. And even if you do not go down that path, a good Front-End developer has a decent understanding of the Back-End and vice versa and naturally a Full-Stack Dev will gravitate to one end over the other. Good luck and you got this!&lt;/p&gt;

&lt;p&gt;Sources&lt;br&gt;
&lt;a href="https://www.freecodecamp.org/news/what-is-a-full-stack-developer-back-end-front-end-full-stack-engineer/"&gt;FreeCodeCamp&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Understanding Data Structures</title>
      <dc:creator>Steven Dawn</dc:creator>
      <pubDate>Fri, 05 Aug 2022 20:49:00 +0000</pubDate>
      <link>https://forem.com/sdwn/understanding-data-structures-3e4c</link>
      <guid>https://forem.com/sdwn/understanding-data-structures-3e4c</guid>
      <description>&lt;p&gt;Welcome to my post about understanding the basics of Data Structures! &lt;/p&gt;

&lt;p&gt;Here, we'll go through a basic overview of the concepts you'll need to learn in order to begin mastering data structures.&lt;/p&gt;

&lt;h2&gt;
  
  
  Array
&lt;/h2&gt;

&lt;p&gt;An array is simply a list of something surrounded by &lt;code&gt;[]&lt;/code&gt; and can contain various data types.&lt;/p&gt;

&lt;p&gt;The simplest data structure, the array serves as the foundation to the data structures we'll go over later in the blog. Here's an example of an array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Shopping List: Chips, Steak, Broccoli, Milk, Eggs

let shoppingList = ["Chips", "Steak", "Broccoli", "Milk", "Eggs"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are no strict rules for adding elements in an array but there will be some for the other data structures we'll look at.&lt;/p&gt;

&lt;h2&gt;
  
  
  Queue
&lt;/h2&gt;

&lt;p&gt;A queue similar to an array, it is a list but when adding or removing elements to a queue but it follows a "&lt;strong&gt;first in, first out&lt;/strong&gt;" rule. &lt;/p&gt;

&lt;p&gt;Essentially, the &lt;em&gt;first&lt;/em&gt; element we add to the queue will also be the &lt;em&gt;first&lt;/em&gt; element to be removed from the queue.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bffCUnlW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v1e5sdroifsivvoq5tgd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bffCUnlW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v1e5sdroifsivvoq5tgd.png" alt="grocery store conveyor belt" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I like to think of Queues as the checkout conveyor belts at the grocery store. The &lt;em&gt;first&lt;/em&gt; thing we put on the belt from our cart will be the &lt;em&gt;first&lt;/em&gt; thing checked out by the clerk!&lt;/p&gt;

&lt;h2&gt;
  
  
  Stack
&lt;/h2&gt;

&lt;p&gt;Also similar to an array and a counterpart to the queue, the difference between those data types and the Stack is that it follows a "&lt;strong&gt;first in, last out&lt;/strong&gt;" rule. Meaning that the &lt;em&gt;first item&lt;/em&gt; we added to the stack will be the &lt;em&gt;last item&lt;/em&gt; removed from it.&lt;/p&gt;

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

&lt;p&gt;I like to think of a stack as a stack of plates where the first plate you add is at the bottom where the last plate you add is at the top.&lt;/p&gt;

&lt;h2&gt;
  
  
  Linked List
&lt;/h2&gt;

&lt;p&gt;Things get a little murky from here on out, starting with Linked Lists. &lt;/p&gt;

&lt;p&gt;Linked Lists has an element (or a node) that has a variable in it where &lt;strong&gt;points&lt;/strong&gt; to another element in memory. So instead of using an array to contain all the data, these elements connect to each other from their own pointer variable that relates them to one another.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1EOTkIy7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w1hjmgz1mmtrjflpuwci.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1EOTkIy7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w1hjmgz1mmtrjflpuwci.jpg" alt="singly and doubly linked list" width="880" height="222"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Linked lists come in two flavors: singly linked or doubly linked.&lt;/p&gt;

&lt;p&gt;Singly linked lists have a head element that points to the next element, to the next element and so on and so forth until reaching element that has a pointer set to &lt;code&gt;NULL&lt;/code&gt;. Doubly linked lists means each element has a next and previous pointer to their respective next/previous elements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trees
&lt;/h2&gt;

&lt;p&gt;Similar to Linked Lists, Trees are a data structure that has elements that point to each other in memory. However instead of having next/previous elements pointing to an element, Trees have a left/right child element. These children elements are what lead to the tree-like structure.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_90mHg6X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/06gi0nznq5kdt5v8wq08.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_90mHg6X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/06gi0nznq5kdt5v8wq08.png" alt="tree data structure" width="570" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The most difficult data structure to understand but when properly implemented, can provide great performance and give you an edge in the interview process!&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This post just scratched the surface of Data Structures but this should get you started on researching and eventually implementing these in your day-to-day work! There are more (and advanced) data structures out in the wild you'll come across on your developer journey. Good luck from here on out!&lt;/p&gt;

&lt;p&gt;Sources&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/data-structures/"&gt;Geek for Geeks&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Getting Started with React</title>
      <dc:creator>Steven Dawn</dc:creator>
      <pubDate>Fri, 01 Jul 2022 20:57:23 +0000</pubDate>
      <link>https://forem.com/sdwn/getting-started-with-react-8ph</link>
      <guid>https://forem.com/sdwn/getting-started-with-react-8ph</guid>
      <description>&lt;p&gt;So, you have just started to get the hang of JavaScript, HTML, and CSS but now you're wondering what the next logical step is in your Web Developer journey? The answer to that, is React.&lt;/p&gt;

&lt;p&gt;React is a JavaScript library created and maintained by Meta.&lt;br&gt;
It is easy to use, fast, and scalable. Developers use it to build complex web applications that can modify data without reloading the page. &lt;/p&gt;

&lt;p&gt;We use React for building user interfaces and we split the different UI elements up into what React calls &lt;strong&gt;Components&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;React's &lt;a href="https://reactjs.org/docs/components-and-props.html"&gt;official documentation on components&lt;/a&gt; summarizes this nicely: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Components let you split the UI into independent, reusable pieces, and think about each piece in isolation.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Really neat huh? Working in different components of your apps is way better than getting lost in a single &lt;code&gt;index.html&lt;/code&gt; page in vanilla JavaScript.&lt;/p&gt;
&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;Before getting into React, make sure you have Node installed on your machine. If you are running into issues installing Node, consult the &lt;a href="https://nodejs.org/en/"&gt;official documentation&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;What I recommend is to make sure you are on Node 16 because Node 17 has issues with several JS libraries. You can check in your Terminal with &lt;code&gt;nvm list&lt;/code&gt;, the &lt;code&gt;-&amp;gt;&lt;/code&gt; lets you know which one is the default.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nvm list

-&amp;gt;     v16.13.0
        v17.0.1
         system
16 (-&amp;gt; v16.13.0)

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

&lt;/div&gt;



&lt;p&gt;If Node 16 is not the default version, you can install it and set it as the default with the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nvm install 16
nvm alias default 16
nvm use 16
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After getting Node sorted, you can create a React project by running this code in your Terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app my-example-app
cd my-example-app
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After running &lt;code&gt;create-react-app&lt;/code&gt; a new browser window will pop up at &lt;code&gt;localhost:3000&lt;/code&gt; with React app created!&lt;/p&gt;

&lt;h2&gt;
  
  
  Components
&lt;/h2&gt;

&lt;p&gt;Opening &lt;code&gt;my-example-app&lt;/code&gt; in your IDE of choice, you will see three directories: &lt;code&gt;./node_modules&lt;/code&gt;, &lt;code&gt;./public&lt;/code&gt;, and &lt;code&gt;./src&lt;/code&gt; we will only be writing our React code in &lt;code&gt;./src&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Opening &lt;code&gt;./src/App.js&lt;/code&gt; will show you the meat and potatoes of how that React Demo screen is rendering all that fancy stuff on &lt;code&gt;localhost:3000&lt;/code&gt; but for now, I'm going to remove everything from lines 7-20 to make things simple&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function App() {
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;h1&amp;gt;Hello, world!&amp;lt;/h1&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;p&gt;Lets break this down: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We have our function &lt;code&gt;App&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;We have a &lt;code&gt;className&lt;/code&gt; that returns our heading &lt;code&gt;Hello, world!&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pretty simple right? Now let's add a content component in our &lt;code&gt;./src&lt;/code&gt; by making sure the first letter of our component is always capitalized so React knows its a component rather than a regular JS file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from "react";

function Content() {
  return (
      &amp;lt;div className="Content"&amp;gt;
          &amp;lt;h1&amp;gt;This is our content!&amp;lt;/h1&amp;gt;
          &amp;lt;img src="https://i.redd.it/9odfz0kwy2i21.jpg" alt="meme"/&amp;gt;
      &amp;lt;/div&amp;gt;
  )
}

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

&lt;/div&gt;



&lt;p&gt;Now when we want to add this content component to our &lt;code&gt;App.js&lt;/code&gt; we would do 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 Content from './Content';

function App() {
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;h1&amp;gt;Hello, world!&amp;lt;/h1&amp;gt;
      &amp;lt;Content /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;p&gt;Lets explain the things we added here: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;import&lt;/code&gt; and &lt;code&gt;export&lt;/code&gt; allows React to pull the code from &lt;code&gt;Content.js&lt;/code&gt; and renders that data in our &lt;code&gt;App.js&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Because &lt;code&gt;&amp;lt;Content /&amp;gt;&lt;/code&gt; is below our &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; we told React that we want our Content component rendered &lt;em&gt;below&lt;/em&gt; our &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  JSX
&lt;/h2&gt;

&lt;p&gt;JSX (aka JavaScript XML) is the special language used to build our component's output. We can actually use JS, HTML and CSS in here! It looks a lot like HTML with some JS here and there but make no mistake JSX is actually closer to JS so here are a few key differences to take note of: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Self-closing tags must end with a slash (example: &lt;code&gt;&amp;lt;img /&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Methods and properties written in JSX must be done in camelCase just like regular JS&lt;/li&gt;
&lt;li&gt;JS expressions can also be used in JSX! Heres an example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const name = 'Steven'
const goodbye = &amp;lt;h1&amp;gt;Goodbye, {name}&amp;lt;/h1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This article covered a &lt;em&gt;very&lt;/em&gt; basic introduction to React where we haven't even scratched the surface with things like State, Inverse Data Flow, and &lt;code&gt;useEffect()&lt;/code&gt; but I hope this article helped you get acquainted with React and some of the first things you will encounter when you first open &lt;code&gt;create-react-app&lt;/code&gt; and see why its the most popular frontend JS library. &lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/"&gt;React Docs&lt;br&gt;
&lt;/a&gt;&lt;a href="https://reactjs.org/docs/components-and-props.html"&gt;Components&lt;/a&gt;&lt;br&gt;
&lt;a href="https://reactjs.org/docs/introducing-jsx.html#gatsby-focus-wrapper"&gt;JSX&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>react</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Intro to Hoisting in JavaScript</title>
      <dc:creator>Steven Dawn</dc:creator>
      <pubDate>Wed, 01 Jun 2022 12:49:42 +0000</pubDate>
      <link>https://forem.com/sdwn/intro-to-hoisting-in-javascript-3bla</link>
      <guid>https://forem.com/sdwn/intro-to-hoisting-in-javascript-3bla</guid>
      <description>&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%2F1crbbhga2x77zbtybhha.jpeg" 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%2F1crbbhga2x77zbtybhha.jpeg" alt="Hoisting Meme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When learning to program in JavaScript you were told by instructors, mentors, or a random person on StackOverflow that you want to avoid hoisting issues in your code by using &lt;code&gt;const&lt;/code&gt; or &lt;code&gt;let&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;But you ask yourself, what the heck is hoisting and why do I need to avoid it? Well, this is the right place to be!&lt;/p&gt;

&lt;p&gt;Hoisting is when the JavaScript engine moves variables and function declarations to the top of their respective scope before code execution.&lt;/p&gt;

&lt;p&gt;Example of Hoisting variable declaration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x = 6
var x;
console.log(x) 
// x would be equal to 6 with no errors thrown
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Naturally, you would think this code would not work because you can't assign a variable and then have the declaration below that right? &lt;/p&gt;

&lt;p&gt;Well, you could do just that with &lt;code&gt;var&lt;/code&gt; because it will initialize variables &lt;em&gt;before&lt;/em&gt; declaration, allowing JavaScript to &lt;em&gt;hoist&lt;/em&gt; it to the top of the function and not throw any errors.  &lt;/p&gt;

&lt;p&gt;Example of Hoisting in function declaration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dogBreed('Miniature Schnauzer')

function dogBreed(name) {
  console.log('My favorite dog breed is the ' + name + '!') 
}
// My favorite dog breed is the Miniature Schnauzer!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Although this code runs just fine, it is best practice to avoid invoking functions before declaring them for readability. &lt;/p&gt;

&lt;p&gt;Mixing these two together can lead to very confusing code. Take this code snippet for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var dogBreed = "Pug";
var favDogBreed = function () {
  console.log("My favorite dog breed: " + dogBreed);
    var dogBreed = "Shih Tzu";
      console.log("Bob's favorite dog breed: " + dogBreed);
};

favDogBreed();
// Original favorite dog: undefined
// New favorite dog: Shih Tzu 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Confusingly enough, JavaScript initialized the first dogBreed to &lt;code&gt;undefined&lt;/code&gt; because of &lt;em&gt;hoisting&lt;/em&gt; and then starts executing the function which is why we got this result. &lt;/p&gt;

&lt;p&gt;Variables that are initialized in JavaScript are not hoisted though. Interestingly enough, the code snippet below prints out &lt;code&gt;NaN&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(x + y)
var x = 4
var y = 2
// Output is NaN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This happens because JavaScript is &lt;em&gt;hoisting&lt;/em&gt; &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; but not their respective initializations &lt;code&gt;= 4&lt;/code&gt; and &lt;code&gt;= 2&lt;/code&gt; resulting in &lt;code&gt;NaN&lt;/code&gt; because &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; are not numbers!&lt;/p&gt;

&lt;p&gt;Thankfully in 2015, we got the ES6 revision of JavaScript and that introduced &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; which effectively outdates &lt;code&gt;var&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Lets take another look &lt;code&gt;favDogBreed&lt;/code&gt; but declare everything with &lt;code&gt;let&lt;/code&gt; instead of &lt;code&gt;var&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let dogBreed = "Pug";
let favDogBreed = function () {
  console.log("My favorite dog breed: " + dogBreed);
    let dogBreed = "Shih Tzu";
      console.log("Bob's favorite dog breed: " + dogBreed);
};

favDogBreed();
// This will throw a ReferenceError and not let this code run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All is now right in the world and the engineer will have to go and fix their confusing code. &lt;/p&gt;

&lt;p&gt;However just because errors are thrown now, does not mean that hoisting is patched out of Javascript. It still occurs with variables declared with &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; but they are never initialized. Take this code snippet for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dogName = "Sparky";
const dogName
console.log(dogName)
// This code doesn't run

dogName = "Sparky";
let dogName
console.log(dogName)
// This results in a ReferenceError
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What does this mean? For starters, hoisting is &lt;em&gt;still&lt;/em&gt; happening with these variables declared with &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; but there are some differences. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;const&lt;/code&gt; refuses run because of syntax error. Same thing happening with &lt;code&gt;let&lt;/code&gt;, but JavaScript sees the variable and is aware of it, but JavaScript cannot use the variable until it has been properly declared.&lt;/p&gt;

&lt;p&gt;When declared with &lt;code&gt;let&lt;/code&gt;, our variable &lt;code&gt;dogName&lt;/code&gt; is in this phenomenon called the &lt;em&gt;&lt;strong&gt;temporal deadzone&lt;/strong&gt;&lt;/em&gt; which yes, would be the sickest name for a band but is what a variable declared with &lt;code&gt;let&lt;/code&gt; or &lt;code&gt;const&lt;/code&gt; is in until JavaScript reaches and executes the line where the variable is declared. &lt;/p&gt;

&lt;p&gt;The temporal deadzone does not apply to &lt;code&gt;var&lt;/code&gt; because JavaScript initializes the variable to undefined when it is accessed &lt;em&gt;before&lt;/em&gt; the declaration.&lt;/p&gt;

&lt;p&gt;The best practices to avoid hoisting issues is to: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Declare variables and functions &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; where ever you can&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Always declare variables at the beginning of each and every scope because this is how JavaScript and developers read code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Never &lt;em&gt;ever&lt;/em&gt; use &lt;code&gt;var&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Congratulations! You now have a better idea of hoisting and how it works in JavaScript ES6. This (often overlooked) concept confuses developers both new and veterans alike and you have an edge in both understanding and avoiding hoisting related bugs in JavaScript!&lt;/p&gt;

&lt;p&gt;Here are some additional resources on the topic:&lt;br&gt;
&lt;a href="https://www.w3schools.com/js/js_hoisting.asp" rel="noopener noreferrer"&gt;W3Schools&lt;/a&gt;&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Hoisting" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;&lt;br&gt;
&lt;a href="https://javascript.info/var" rel="noopener noreferrer"&gt;JavaScript Docs&lt;/a&gt;&lt;/p&gt;

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