<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gabriella Elizondo on Medium]]></title>
        <description><![CDATA[Stories by Gabriella Elizondo on Medium]]></description>
        <link>https://medium.com/@ellazondo?source=rss-53553e8a6c67------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*2UN9aomZ1uucyccWP9PkQQ.jpeg</url>
            <title>Stories by Gabriella Elizondo on Medium</title>
            <link>https://medium.com/@ellazondo?source=rss-53553e8a6c67------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 00:15:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ellazondo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Authentication & Authorization Walkthrough.]]></title>
            <link>https://medium.com/@ellazondo/authentication-authorization-walkthrough-c36504035769?source=rss-53553e8a6c67------2</link>
            <guid isPermaLink="false">https://medium.com/p/c36504035769</guid>
            <dc:creator><![CDATA[Gabriella Elizondo]]></dc:creator>
            <pubDate>Wed, 29 Mar 2023 22:00:24 GMT</pubDate>
            <atom:updated>2023-03-29T22:12:25.090Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the most important aspects of any web application is security, and authentication and authorization are two key components of this. In this blog, we’ll take a closer look at how Ruby on Rails handles authentication and authorization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9nUHRnXgumxvFIdR3BTaKA.png" /></figure><p>Authentication is the process of verifying the identity of a user. For example, showing your id at the club. In a web application, this usually involves having the user enter a username and password, which are then verified against a database of user credentials.</p><p>This starts with the user signing up on the frontend:</p><pre>        &lt;form onSubmit={onSignup}&gt;<br>            &lt;h1&gt;Sign Up:&lt;/h1&gt;<br>            &lt;label&gt;Username: &lt;/label&gt;<br>            &lt;input type=&quot;text&quot; name=&quot;username&quot; onChange={updateSignupFormData}/&gt;&lt;br/&gt;<br>            <br>            {/* Allow the user to enter a password into the signup form */}<br>            &lt;label&gt;Password: &lt;/label&gt;<br>            &lt;input type=&quot;text&quot; name=&quot;password&quot; onChange={updateSignupFormData}/&gt;&lt;br/&gt;<br>            &lt;input type=&quot;submit&quot;/&gt;<br>        &lt;/form&gt;<br></pre><p>When anything is typed into the username or password input, the onChange is triggered and initiates the updateSignupFormData. The username and password are saved using key value pair:</p><pre>[event.target.name]: event.target.value}</pre><p>These are added after the spread operator for signupFormData and then sets the state for SignupFormData. Upon submission of the form, onSubmit={onSignup} is initiated in App.js because it is passed as a prop.</p><pre>const [signupFormData, setSignupFormData] = useState({})<br>const [user, setUser] = useState(null)<br><br>function updateSignupFormData(event){<br>    setSignupFormData({...signupFormData, [event.target.name]: event.target.value})<br>  }<br><br>  function onSignup(event){<br>    event.preventDefault()<br>    fetch(&quot;/signup&quot;, {<br>      method: &quot;POST&quot;,<br>      headers: {<br>        &quot;Content-Type&quot;: &quot;application/json&quot;<br>      },<br>      body: JSON.stringify(signupFormData)<br>    })<br>    .then(response =&gt; {<br>      if(response.ok){<br>        response.json().then(userData =&gt; setUser(userData))<br>      }<br>      else if(response.status === 422){<br>        alert(&quot;Error: Username already exists or invalid Username! Please try again!&quot;)<br>      }<br>      else{<br>        alert(`Error: ${response.status} ${response.statusText}`)<br>      }<br>    })<br>  }<br><br>return (<br>&lt;Signup onSignup={onSignup} updateSignupFormData={updateSignupFormData} /&gt;<br>);</pre><p>The onSignup function initiates a POST fetch, stringifies the signupFormData state that has been set and uses that JSON data to set the user state.</p><p>Let’s follow this post to the backend:</p><pre>Rails.application.routes.draw do<br>  post &quot;/signup&quot;, to: &quot;users#create&quot;<br>end</pre><p>We see that our routes enables a post request through local host signup and sends it to our users controller:</p><pre>class UsersController &lt; ApplicationController    <br><br>def create<br>        new_user = User.create(user_params)<br>        if(new_user.valid?)<br>            session[:user_id] = new_user.id<br>            render json: new_user, status: :created<br>        else<br>            render json: { errors: new_user.errors.full_messages }, status: :unprocessable_entity<br>        end<br>    end<br><br>private<br>    def user_params<br>        params.permit(:username, :password)<br>    end<br><br>end</pre><p>This will save the username and password to the backend and assign it to an id number.</p><p>Now the user is able to login. So let’s head back to the front end, to the login component:</p><pre>function Login({onLogin, updateLoginFormData}){<br>    return (<br>        &lt;form onSubmit={onLogin}&gt;<br>            &lt;h1&gt;Log In:&lt;/h1&gt;<br>            &lt;label&gt;Username: &lt;/label&gt;<br>            &lt;input type=&quot;text&quot; name=&quot;username&quot; onChange={updateLoginFormData}/&gt;&lt;br/&gt;<br><br>            {/* Allow the user to enter a password into the login form */}<br>            &lt;label&gt;Password: &lt;/label&gt;<br>            &lt;input type=&quot;text&quot; name=&quot;password&quot; onChange={updateLoginFormData}/&gt;&lt;br/&gt;<br>            &lt;input type=&quot;submit&quot;/&gt;<br>        &lt;/form&gt;<br>    )<br>}<br><br>export default Login;</pre><p>The user is now able to go to the login page and fill in their username and password. Because they have already signed up, they have been saved to the backend and will be recognized. So upon submission, the onLogin and updateLoginFormData are able to be used as props in App.js.</p><pre>const [loginFormData, setLoginFormData] = useState({})<br><br>  function onLogin(event){<br>    event.preventDefault()<br>    fetch(&quot;/login&quot;, {<br>      method: &quot;POST&quot;,<br>      headers: {<br>        &quot;Content-Type&quot;: &quot;application/json&quot;<br>      },<br>      body: JSON.stringify(loginFormData)<br>    })<br>    .then(response =&gt; {<br>      if(response.ok){<br>        response.json().then(userData =&gt; setUser(userData))<br>      }<br>      else if(response.status === 401){<br>        alert(&quot;Error: Invalid username or password! Please try again!&quot;)<br>      }<br>      else{<br>        alert(`Error: ${response.status} ${response.statusText}`)<br>      }<br>    })<br>  }<br><br>  function updateLoginFormData(event){<br>    setLoginFormData({...loginFormData, [event.target.name]: event.target.value})<br>  }</pre><p>The onLogin function will do a POST fetch sending the loginFormData and then sets the user. The updateLoginFormData function will take the key and value pairs from the username and password form and add them to the loginFormData using the spread operator, which is then set to the loginFormData.</p><p>In Ruby on Rails, there are several authentication frameworks available, including Devise, Clearance, and Sorcery. Devise is the most popular of these frameworks, and it provides a range of authentication features out of the box. But we haven’t gotten to all of those yet. I am excited to dive in further!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c36504035769" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Relationships in Ruby.]]></title>
            <link>https://medium.com/@ellazondo/relationships-in-ruby-b5c44192aeba?source=rss-53553e8a6c67------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5c44192aeba</guid>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Gabriella Elizondo]]></dc:creator>
            <pubDate>Wed, 15 Feb 2023 15:36:12 GMT</pubDate>
            <atom:updated>2023-02-15T15:36:12.458Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*VHCF-QMNxxs-DgV-Rzz4_Q.png" /></figure><p>With valentines day behind us, let’s discuss the complexity of Relationships… in coding terms. In Ruby, relationships are a lot more clear to distinguish and define than in real life. In Ruby, everything is an object and relationships between objects can be established using various techniques, including associations, inheritance, and modules.</p><ol><li>Associations: In Ruby on Rails, associations are used to define relationships between different models in a web application. There are several types of associations in Rails, including one-to-one, one-to-many, many-to-many, and others.</li></ol><pre>class Doctor &lt; ApplicationRecord<br>  has_many :patients<br> end<br><br>class Patient &lt; ApplicationRecord<br>  belongs_to :doctor<br>end<br><br>doc = Doctor.first<br>doc.patients #returns an array of all the patients associated with that doctor</pre><p>In this example, the ‘Doctor’ model has many ‘Patients’ and the ‘Post” model belongs to a ‘Doctor’. This creates a one-to-many relationship between doctors and patients, where each doctor can have many patients and each patient belongs to a single doctor.</p><p>2. Inheritance: Ruby allows classes to inherit characteristics and behaviors from a parent class. The child class can inherit all or some of the methods and attributes of the parent class, and can also add or modify them to fit its own needs.</p><pre>class Animal<br>  def speak<br>    &quot;Hello&quot;<br>  end<br>end<br><br>class Cat &lt; Animal<br>  def speak<br>    &quot;#{super}, Meow!&quot;<br>  end<br>end<br><br>dog = Cat.new<br>dog.speak # &quot;Hello, Meow!&quot;<br></pre><p>3. Modules: Ruby also allows for relationships to be established through the use of modules. Modules are collections of methods and constants that can be included in multiple classes.</p><pre>module Greeting<br>  def greet<br>    &quot;Hello&quot;<br>  end<br>end <br><br>class Animal<br>  include Greeting<br>end<br><br>class Horse &lt; Animal<br>end<br><br>horse = Horse.new<br>horse.greet #&quot;Hello&quot;<br>  </pre><p>Let’s take the Doctor and Patient relationship a bit further by adding appointments. Doctors have many appointments but the same goes for patients. This is called a many-to-many relationship. Doctors have many patients, through appointments and patients have many doctors through appointments. Appointments acts as a join model, allowing them to communicate with each other and exchange data. The purpose of this bridge model is to represent a many-to-many relationship between two other models in a more intuitive and manageable way.</p><pre>class Doctor &lt; ApplicationRecord<br>  has_many :patients, through: :appointments<br> end<br><br>class Patient &lt; ApplicationRecord<br>  has_many :doctors, through: :appointments<br>end<br><br>class Appointment &lt; ApplicationRecord<br>  belongs_to :doctor<br>  belongs_to :patient<br>end<br></pre><p>Moving into the project for phase-3, my project team and I wanted to create a website that can help you create outfits. This website would start with the UI that supplied 3 sliding rows of tops, bottoms, and shoes. The user will be able to click on 1 top, 1 bottom and 1 pair of shoes and then hit submit to create an outfit that would be saved in their “closet”. So the question is how do we create the relationships here?</p><pre>class Product &lt; ApplicationRecord<br>    has_many :outfit_products<br>    has_many :outfits, through: :outfit_products<br>end<br><br>class Outfit &lt; ApplicationRecord<br>    has_many :outfit_products<br>    has_many :products, through: :outfit_products<br>end<br><br>class OutfitProduct &lt; ApplicationRecord<br>    belongs_to :outfit<br>    belongs_to :product<br>end<br><br><br>      </pre><p>At first, these relationships were not very straight forward. But taking one step further helps solidify the understanding. We need to create the tables.</p><pre>20230213252307_create_products.rb<br>class CreateProducts &lt; ActiveRecord::Migration[7.0]<br>  def change<br>    create_table :products do |t|<br>      t.string :name<br>      t.string :category<br>      t.string :style<br>      t.string :link<br>    end<br>  end<br>end<br><br>20230213222304_create_outfits.rb<br>class CreateOutfits &lt; ActiveRecord::Migration[7.0]<br>  def change<br>    create_table :outfits do |t|<br>      t.string :name<br>      t.integer :latitude<br>      t.integer :longitude<br>      t.integer :user_id<br>      <br>    end<br>  end<br>end<br><br>20230213222618_create_outfit_products.rb<br>class CreateOutfitProducts &lt; ActiveRecord::Migration[7.0]<br>  def change<br>    create_table :outfit_products do |t|<br>      t.integer :outfit_id<br>      t.integer :product_id<br>    end<br>  end<br>end<br><br></pre><p>Once we started using the console for testing, it became a lot more clear. In order to test your relationships, you need to create seeds.</p><pre>p &quot;Planting seeds...&quot;<br><br>p &quot;Product seeding&quot;<br>product15=Product.create(name: &#39;Pink wedges&#39;, category: &#39;shoes&#39;, style: &#39;aura&#39;, link: &#39;https://images.urbndata.com/is/image/FreePeople/69667194_062_b/?$a15-pdp-detail-shot$&amp;fit=constrain&amp;fmt=webp&amp;qlt=80&amp;wid=1080&#39;)<br>product16=Product.create(name: &#39;Simple Tee&#39;, category: &#39;top&#39;, style: &#39;ella&#39;, link: &#39;https://images.urbndata.com/is/image/FreePeople/81264939_211_b/?$a15-pdp-detail-shot$&amp;fit=constrain&amp;fmt=webp&amp;qlt=80&amp;wid=1080&#39;)<br>product17=Product.create(name: &#39;Simple Tank&#39;, category: &#39;top&#39;, style: &#39;ella&#39;, link: &#39;https://images.urbndata.com/is/image/FreePeople/81633422_011_c/?$a15-pdp-detail-shot$&amp;fit=constrain&amp;fmt=webp&amp;qlt=80&amp;wid=1080&#39;)<br>product18=Product.create(name: &#39;Vest&#39;, category: &#39;top&#39;, style: &#39;ella&#39;, link: &#39;https://images.urbndata.com/is/image/FreePeople/69601359_016_c/?$a15-pdp-detail-shot$&amp;fit=constrain&amp;fmt=webp&amp;qlt=80&amp;wid=1080&#39;)<br>product19=Product.create(name: &#39;Blazer&#39;, category: &#39;top&#39;, style: &#39;ella&#39;, link: &#39;https://images.urbndata.com/is/image/FreePeople/69286383_000_a/?$a15-pdp-detail-shot$&amp;fit=constrain&amp;fmt=webp&amp;qlt=80&amp;wid=1080&#39;)<br>product20=Product.create(name: &#39;Boyfriend buttondown&#39;, category: &#39;top&#39;, style: &#39;ella&#39;, link: &#39;https://images.urbndata.com/is/image/FreePeople/62495387_211_a/?$a15-pdp-detail-shot$&amp;fit=constrain&amp;fmt=webp&amp;qlt=80&amp;wid=1080&#39;)<br>product21=Product.create(name: &#39;Classic trouser&#39;, category: &#39;bottom&#39;, style: &#39;ella&#39;, link: &#39;https://images.urbndata.com/is/image/FreePeople/63797138_001_h/?$a15-pdp-detail-shot$&amp;fit=constrain&amp;fmt=webp&amp;qlt=80&amp;wid=1080&#39;)<br>product22=Product.create(name: &#39;High Rise Jeans&#39;, category: &#39;bottom&#39;, style: &#39;ella&#39;, link: &#39;https://images.urbndata.com/is/image/FreePeople/78713609_001_a/?$a15-pdp-detail-shot$&amp;fit=constrain&amp;fmt=webp&amp;qlt=80&amp;wid=1080&#39;)<br>product23=Product.create(name: &#39;Linnen Shorts&#39;, category: &#39;bottom&#39;, style: &#39;ella&#39;, link: &#39;https://images.urbndata.com/is/image/FreePeople/67222133_010_c/?$a15-pdp-detail-shot$&amp;fit=constrain&amp;fmt=webp&amp;qlt=80&amp;wid=1080&#39;)<br>product24=Product.create(name: &#39;Matching Suit&#39;, category: &#39;bottom&#39;, style: &#39;ella&#39;, link: &#39;https://images.urbndata.com/is/image/FreePeople/69601359_016_a/?$a15-pdp-detail-shot$&amp;fit=constrain&amp;fmt=webp&amp;qlt=80&amp;wid=1080&#39;)<br>product25=Product.create(name: &#39;Set Skirt&#39;, category: &#39;bottom&#39;, style: &#39;ella&#39;, link: &#39;https://images.urbndata.com/is/image/FreePeople/69286383_000_d/?$a15-pdp-detail-shot$&amp;fit=constrain&amp;fmt=webp&amp;qlt=80&amp;wid=1080&#39;)<br>product26=Product.create(name: &#39;Margo Mules&#39;, category: &#39;shoes&#39;, style: &#39;ella&#39;, link: &#39;https://images.urbndata.com/is/image/FreePeople/78729506_111_d/?$a15-pdp-detail-shot$&amp;fit=constrain&amp;fmt=webp&amp;qlt=80&amp;wid=1080&#39;)<br>product27=Product.create(name: &#39;Veja Sneaks&#39;, category: &#39;shoes&#39;, style: &#39;ella&#39;, link: &#39;https://images.urbndata.com/is/image/FreePeople/62519798_008_d/?$a15-pdp-detail-shot$&amp;fit=constrain&amp;fmt=webp&amp;qlt=80&amp;wid=1080&#39;)<br>product28=Product.create(name: &#39;Ankle Boots&#39;, category: &#39;shoes&#39;, style: &#39;ella&#39;, link: &#39;https://images.urbndata.com/is/image/FreePeople/68272350_014_c/?$a15-pdp-detail-shot$&amp;fit=constrain&amp;fmt=webp&amp;qlt=80&amp;wid=1080&#39;)<br>product29=Product.create(name: &#39;Black flats&#39;, category: &#39;shoes&#39;, style: &#39;ella&#39;, link: &#39;https://images.urbndata.com/is/image/FreePeople/55476378_001_a/?$a15-pdp-detail-shot$&amp;fit=constrain&amp;fmt=webp&amp;qlt=80&amp;wid=1080&#39;)<br>product30=Product.create(name: &#39;Slide Sandals&#39;, category: &#39;shoes&#39;, style: &#39;ella&#39;, link: &#39;https://images.urbndata.com/is/image/FreePeople/56313224_111_c/?$a15-pdp-detail-shot$&amp;fit=constrain&amp;fmt=webp&amp;qlt=80&amp;wid=1080&#39;)<br><br><br>p &quot;Done seeding!&quot;</pre><p>After this, in the terminal you need to run rails db:seed. Then you can run rails console. You can start by asking for a Product instance:</p><pre>$ Product.first</pre><p>This will then return the first product and return the information from the first product. Including the name, category, style, and link.</p><pre>#&lt;Product:0x00000001104932c8                                                        <br> id: 1,                                                                             <br> name: &quot;Black corset&quot;,                                                              <br> category: &quot;top&quot;,                                                                   <br> style: &quot;aura&quot;,                                                                     <br> link:                                                         <br>  &quot;https://images.urbndata.com/is/image/FreePeople/65005944_001_a/?$a15-pdp-detail-shot$&amp;fit=constrain&amp;fmt=webp&amp;qlt=80&amp;wid=1080&quot;&gt; </pre><p>Now, let’s try and create an outfit in the terminal using rail console.</p><pre>$ Outfit.create(name:&quot;test)</pre><p>It returns:</p><pre>=&gt; #&lt;Outfit:0x00000001359eb200 id: 4, name: &quot;test&quot;&gt; </pre><p>Now, let’s create an OutfitProduct in the terminal using rails console:</p><pre>$ OutfitProduct.create(outfit_id: 4, product_id: 15)</pre><p>Terminal returns:</p><pre>=&gt; #&lt;OutfitProduct:0x000000014002e770 id: 4, outfit_id: 4, product_id: 15&gt;  </pre><p>We have now created a new outfit that thus far contains one product. And we can confirm that test in the console:</p><pre>2.7.4 :005 &gt; OutfitProduct.fourth.product<br>  OutfitProduct Load (0.2ms)  SELECT &quot;outfit_products&quot;.* FROM &quot;outfit_products&quot; ORDER BY &quot;outfit_products&quot;.&quot;id&quot; ASC LIMIT ? OFFSET ?  [[&quot;LIMIT&quot;, 1], [&quot;OFFSET&quot;, 3]]                        <br>  Product Load (0.1ms)  SELECT &quot;products&quot;.* FROM &quot;products&quot; WHERE &quot;products&quot;.&quot;id&quot; = ? LIMIT ?  [[&quot;id&quot;, 15], [&quot;LIMIT&quot;, 1]]                                                                  <br> =&gt;                                                                                        <br>#&lt;Product:0x000000014038e078                                                               <br> id: 15,                                                                                   <br> name: &quot;Pink wedges&quot;,                                                                      <br> category: &quot;shoes&quot;,                                                                        <br> style: &quot;aura&quot;,                                                                            <br> link:                                                                                     <br>  &quot;https://images.urbndata.com/is/image/FreePeople/69667194_062_b/?$a15-pdp-detail-shot$&amp;fit=constrain&amp;fmt=webp&amp;qlt=80&amp;wid=1080&quot;&gt;                                                          <br>2.7.4 :006 &gt; </pre><p>In the end, relationships are a bit more simplistic in coding however do not fall into place when it comes to human nature. With Ruby, we are able to house data in an organized manner and let Ruby know how we want all of the information to relate to each other. If only life were as simple and straightforward. Happy Valentines day.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5c44192aeba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Importing External Components to React.]]></title>
            <link>https://medium.com/@ellazondo/react-external-components-vs-react-bootstrap-65ad48ae6d8?source=rss-53553e8a6c67------2</link>
            <guid isPermaLink="false">https://medium.com/p/65ad48ae6d8</guid>
            <category><![CDATA[spinner]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[bootstrap]]></category>
            <dc:creator><![CDATA[Gabriella Elizondo]]></dc:creator>
            <pubDate>Wed, 25 Jan 2023 15:51:54 GMT</pubDate>
            <atom:updated>2023-01-25T19:25:15.857Z</atom:updated>
            <content:encoded><![CDATA[<p>How we can use external components inside your applications. This is fascinating because you can use components that other developers have created. For example, when the data is loading, I only have “Data Loading” rendered on the screen while the user is waiting to see the temperature in Sydney.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*vb9uQFOjtjX5F37_OusZ5Q.png" /></figure><p>This user experience isn’t that fun, wouldn’t it be cool if we added something more exciting to keep the user interested during the loading process? For example, those little buffering dots that spin in a circle. To do this ourselves we would have to import an image, and add a lot of css. Thankfully, we have a lot of resources online that do this for us! Simply go to Google and search for React Loader to find the first result: <a href="https://www.npmjs.com/package/react-loader-spinner">react-loader-spinner — npm</a> (node package manager). Here you will find many packages that were created by other developers that were nice enough open source their work. For example the first package is a react-loader-spinner.</p><p>Let’s get started. You always have to go through a few steps when you go through an external library. We have already used React as an external library by opening vs code and placing the following in the terminal:</p><pre>$ npm i create-react-app<br>$ npm start</pre><p>Now we can add another external library called react-loader-spinner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VJbdzEj-FN5Fqq5AcZTOIA.png" /></figure><p>Using npm, you can use the following command in the terminal:</p><pre>$ npm install react-loader-spinner</pre><p>I added the code provided by the website to the desired area and inserted the Loader at the top of the page.</p><pre>App.js<br>import Loader from &quot;react-loader-spinner&quot;;<br><br>&lt;Loader <br>  type= &quot;Puff&quot;<br>  color= &quot;#00BFFF&quot;<br>  height= {100}<br>  width= {100}<br>  timeout= {3000} //3 secs<br>/&gt;<br></pre><p>Unfortunately, I continued to get an error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UM3oYBFTch2eJmHiAqkxMg.png" /></figure><p>After loads of googling, I realized that this external component is only used in code sandbox; while I am using visual code studio. So what is my solution?</p><p>What is another way I could incorporate a previously assembled and open sourced package? BOOTSTRAP! And in this case… React Bootstrap. There is a difference! So first, head to the <a href="https://react-bootstrap.netlify.app/getting-started/introduction/">React Bootstrap website</a>. It has lovely directions to help you get started. Step one: install npm package via the terminal:</p><pre>$ npm install react-bootstrap bootstrap</pre><p>Step 2: Browser globals. Bootstrap provides react-bootstrap.js bundles with all components exported on the window.ReactBootstrap object. In index.html &lt;head&gt;, insert the following:</p><pre>&lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot; integrity=&quot;sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD&quot; crossorigin=&quot;anonymous&quot;&gt;</pre><p>Then browse bootstrap for an effect you want to import into your code. Look at the left bar under introductions and click on components. Let’s continue what we were trying to accomplish before, and choose <a href="https://react-bootstrap.netlify.app/components/spinners/">Spinners</a>. The page gives you lots of examples. I personally like the spinning circle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iPeNfphayBodth3ib0bzNQ.png" /></figure><p>The spinner looks like a C in the screenshot above, but it is an animation that continuously spins! So in the directions above, you can choose your desired Component and add the following:</p><pre>import Spinner from &#39;react-bootstrap/Spinner&#39;;<br><br>export default function BorderExample() {<br>&lt;Spinner animation= &quot;border&quot; /&gt;<br>}</pre><p>And this time… IT WORKED! Bootstrap does not end there though! You can then continue to modify the size, color, animation timing, or even create a button with a spinner. Then outside of there, you can add even more components other than a spinner. For example, you can add Alerts, Drop-downs, Nav-bars, Tables and much more. Bootstrap is a simple and fast way to incorporate interesting and eye catching effects that have been previously assembled by other developers. And it works on VS code!</p><p>So now that I am in the last week of Phase-2, I am working on my project built using React. I have followed my above steps to include Bootstrap and the Spinner Component. See the following code:</p><pre>import React, { useState } from &quot;react&quot;;<br>import &quot;./Weather.css&quot;;<br>import axios from &quot;axios&quot;;<br>import Spinner from &quot;react-bootstrap/Spinner&quot;;<br><br>export default function Weather() {<br>  const [ready, setReady] = useState(false);<br>  const [temperature, setTemperature] = useState(null);<br>  const [humidity, setHumidity] = useState(&quot;&quot;);<br>  const [wind, setWind] = useState(&quot;&quot;);<br><br>  function handleResponse (response) {<br>    setTemperature(Math.round(response.data.main.temp));<br>    setHumidity(response.data.main.humidity);<br>    setWind(response.data.wind.speed);<br>    setReady(true);<br>  }<br><br>  if (ready) {<br>    return (<br>         &lt;div className=&quot;Weather&quot;&gt;<br>      &lt;form&gt;<br>        &lt;div className=&quot;row&quot;&gt;<br>          &lt;div className=&quot;col-9&quot;&gt;<br>            &lt;input<br>              type=&quot;search&quot;<br>              placeholder=&quot;Enter a city&quot;<br>              className=&quot;form-control&quot;<br>              autoFocus=&quot;on&quot;<br>            /&gt;<br>          &lt;/div&gt;<br>          &lt;div className=&quot;col-3&quot;&gt;<br>            &lt;input type=&quot;submit&quot; value=&quot;search&quot; className=&quot;btn btn-primary w-100&quot; /&gt;<br>          &lt;/div&gt;<br>        &lt;/div&gt;<br>      &lt;/form&gt;<br>      &lt;h1&gt;New York&lt;/h1&gt;<br>      &lt;ul&gt;<br>        &lt;li&gt;Wednesday 07:00&lt;/li&gt;<br>        &lt;li&gt;Mostly Cloudy&lt;/li&gt;<br>      &lt;/ul&gt;<br>      &lt;div className=&quot;row&quot;&gt;<br>        &lt;div className=&quot;col-6&quot;&gt;<br>          &lt;img<br>            src=&quot;https://ssl.gstatic.com/onebox/weather/64/partly_cloudy.png&quot;<br>            alt=&quot;Mostly Cloudy&quot;<br>          /&gt;<br>          &lt;strong&gt;{temperature}&lt;/strong&gt; °F <br>        &lt;/div&gt;<br>        &lt;div className=&quot;col-6&quot;&gt;<br>          &lt;ul&gt;<br>            &lt;li&gt;Percipitation: 15%&lt;/li&gt;<br>            &lt;li&gt;Humidity: {humidity}%&lt;/li&gt;<br>            &lt;li&gt;Wind: {wind} km/h&lt;/li&gt;<br>          &lt;/ul&gt;<br>        &lt;/div&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>    );<br>  } else {<br>    const apiKey = &quot;7e51999498b98449960c3d517772a9e2&quot;;<br>  let city = &quot;New York&quot;;<br>  let apiUrl = `https://api.openweathermap.org/data/2.5/weather?q=${city}&amp;appid=${apiKey}&amp;units=imperial`<br>  axios.get(apiUrl).then(handleResponse);<br>  return ( <br>    &lt;Spinner animation=&quot;grow&quot; variant=&quot;success&quot; /&gt;  <br>  );<br>  }<br>  <br>}</pre><p>I am using the Spinner to return while Axios is fetching the weather data. I had to first create a useState for ready which is set to false. Then the return is based on the state of ‘ready’. Initially it will be false so the code will jump to the ‘else’ which initiates the fetch. Once the fetch is complete it calls the function ‘handleResponse’, which changes the state of all the data that needs to be populated; the last state to change is ‘ready’ to true. So then upon the re-render, the ‘return’ can be initiated because ‘ready’ is now true after the fetch is complete and handleSubmit has been called. Unfortunately, in this case, the fetch goes so fast that the loader never displays on the screen. Which leads me to my next blog post topic, how to implement setTimeout. Thank you.</p><p>Resources:</p><p><a href="https://react-bootstrap.netlify.app/components/navs/">https://react-bootstrap.netlify.app/components/navs/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65ad48ae6d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Phase-1: What got me through the weeds.]]></title>
            <link>https://medium.com/@ellazondo/phase-1-what-got-me-through-the-weeds-310cbf44687e?source=rss-53553e8a6c67------2</link>
            <guid isPermaLink="false">https://medium.com/p/310cbf44687e</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[study-methods]]></category>
            <category><![CDATA[codingbootcamp]]></category>
            <dc:creator><![CDATA[Gabriella Elizondo]]></dc:creator>
            <pubDate>Mon, 02 Jan 2023 19:12:23 GMT</pubDate>
            <atom:updated>2023-01-03T20:53:36.160Z</atom:updated>
            <content:encoded><![CDATA[<p>When I first started learning coding basics, I was compelled to write the code down. I thought to myself: “How silly, you are starting a new career in tech and you want to put pen to paper?” However, in the end I realized this bridged a gap with my brain and what appeared on the screen. This was confirmed when I asked my classmates how they understood some of the concepts; they responded that it came from reading it from a physical book. So I Amazon’ed ‘Eloquent Javascript’ and went out to buy as many different colored pens and highlighters as Walgreens would provide.</p><p>The first confusion I was able to sort out with paper and highlighters was combining event listeners and for.. each loops. This helped me get through my first code challenge. Then comes the first group project which entails creating a single page application(SPA) that fetches a data from an external API and displays this information nicely using HTML and CSS, and makes it interactive by applying event listeners such as click and submit. Finally, we had to make any changes made by user interaction… permanent, even after you refresh the page. This is done using POST, PATCH and/or DELETE. This subject was my next hurdle to overcome, so I went back to pen and paper.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qVX8zshinnPO5wFYqA9jFg.jpeg" /><figcaption>Photo created and provided by Gabriella Elizondo.</figcaption></figure><p>As helpful as this was, it was difficult to rearrange or follow to the next page. So then I went back to typing it up on a mac pages document. This still allowed me to highlight, however the added comments became a bit overwhelming.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mH4h1C281UwdvHoVjxtMkA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vWfXarnQtCXFDkJOEtYUug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RjIVxklXkvWuyWfw6pFFYA.png" /><figcaption>Screenshots created and provided by Gabriella Elizondo.</figcaption></figure><p>This tactic has helped immensely as my eyes can more easily connect and comprehend the code. I used the // method for comments and colored them all green (they turn green in vs code as well). If I went a step further, I would print the above out and add arrows to understand the flow of communication. I realize this may be a bit overkill, but the results will not disappoint.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=310cbf44687e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>