<?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 Laura Keat on Medium]]></title>
        <description><![CDATA[Stories by Laura Keat on Medium]]></description>
        <link>https://medium.com/@laurakeatdev?source=rss-b58159e8bcb7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*s8k80EgvxKx19awshdMTpA.jpeg</url>
            <title>Stories by Laura Keat on Medium</title>
            <link>https://medium.com/@laurakeatdev?source=rss-b58159e8bcb7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 17:07:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@laurakeatdev/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[Typescript: Pain or Pain Relief?]]></title>
            <link>https://laurakeatdev.medium.com/typescript-pain-or-pain-relief-4d256d47d58c?source=rss-b58159e8bcb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d256d47d58c</guid>
            <category><![CDATA[tuples]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[typesetting]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming-languages]]></category>
            <dc:creator><![CDATA[Laura Keat]]></dc:creator>
            <pubDate>Wed, 24 May 2023 00:31:58 GMT</pubDate>
            <atom:updated>2023-07-11T18:55:58.510Z</atom:updated>
            <content:encoded><![CDATA[<p>Looking through entry level job searches for developers I’ve been seeing plenty of requirements to have experience with TypeScript. I decided to look into TypeScript a little more to understand exactly what it is and how it relates to JavaScript.</p><p>The first thing I was told is that TypeScript is “a pain in the ass”. As I read more about it I discovered why some might see it as a pain some might see it as pain relief.</p><p>First of all, what is TypeScript? It’s a programming language that adds types to JavaScript. It was developed by Microsoft to blend the flexibility of JavaScript with the benefits of stricter languages like Java, C, C++, etc. The stricter languages are typically used for large scale applications. A language that combines these two strengths not only made sense, but is becoming very popular and widely used.</p><h3>Pros &amp; Cons</h3><p>There are always pros and cons to using any programming language and here are a few common ones that I found:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pa2vKHkSqFCTHi731zHlGA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QIdgqCyFFAUXJEhBP3sXUQ.png" /></figure><p>Basically, TypeScript is a superset of JavaScript, meaning it has all the features of JavaScript but with extra features. These extra features help with catching bugs before compiling and even while writing the code. They make coding with a team easier because of it’s readability with declaring types which also makes it more predictable. <br>The drawback is it can take more time to learn since you have to know JavaScript already and build upon that. Some developers think the code is verbose and cluttered or that it’s not even true static typing because the type declaration is optional. <br>Choosing what’s best can change from project to project depending on application size, number of team members, need for scalability and so on.</p><h3>How it works</h3><p>TypeScript can spot potential bugs, clarify the structure of, and help refactor code by utilizing a set of tools called a type system. It’s type system is different than other static languages because the typing is optional and therefore regular JavaScript technically *is* TypeScript. It works in essentially three steps: <br>1) Put TypeScript code into a .ts or .tsx file<br>2) Run code through the TypeScript transpiler<br>3) If code is working, output is a version of JavaScript</p><p>The <strong>primitive types</strong> are strings, numbers, booleans, undefined and null. The data type of all variables within the code are expected to be the same type as the original variable when it was declared. This is called type inference.</p><p>I can declare that a variable is a string by writing:<br> let cat : string = &quot;Simba&quot; <br>Now if I try to set cat to a number or boolean I’ll get an error saying<br> error TS2322:Type &#39;number&#39; is not assignable to type &#39;string’.<br>This can be carried over to numbers and booleans in the same manner.</p><p>When a type is not explicitly declared through declarations or annotations, TypeScript infers types of variables. There is an exception to the basic type inference because there is an ‘any’ type. This means that a variable can be reassigned to a different type. An example would be:<br> let simbaAge : any = &quot;six&quot; <br>This means that I could later change it to:<br> simbaAge = 6</p><p>Other types of data include but are not limited to: arrays, tuples, unions, enums, objects, and any (as demonstrated above). Tuples are particularly interesting because of the benefits of type declarations. Tuples are essentially arrays, that have different data types. Tuples can be very bug prone due to user error in dealing with different data types and keeping them in order. This is where declaring types can be super useful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MSkb2CynPMlyldq7qm54xA.png" /></figure><p>TypeScript is a very useful language that may be a little tricky to get the hang of, but is worth the benefits. I’ll be studying it more in the future and will share as I get past the basic low down.</p><p>Resources: <br>TypeScript: <a href="https://www.typescriptlang.org/">https://www.typescriptlang.org/</a></p><p>Codecademy: <a href="https://www.codecademy.com/">https://www.codecademy.com/</a><br>Typescript course</p><p>TypeScript Deep Dive: <a href="https://basarat.gitbook.io/typescript/type-system">https://basarat.gitbook.io/typescript/type-system</a></p><p>Traversy Media youTube channel: <a href="https://youtu.be/BCg4U1FzODs">https://youtu.be/BCg4U1FzODs</a><br>TypeScript Crash Course</p><p>Codevolution youTube channel: <a href="https://youtu.be/TiSGujM22OI">https://youtu.be/TiSGujM22OI</a><br>React TypeScript Tutorial</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d256d47d58c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bootstrap Iterating through an Accordion in React]]></title>
            <link>https://laurakeatdev.medium.com/bootstrap-iterating-through-an-accordion-in-react-c9d686a062df?source=rss-b58159e8bcb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9d686a062df</guid>
            <category><![CDATA[accordion]]></category>
            <category><![CDATA[iterate]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[bootstrap]]></category>
            <dc:creator><![CDATA[Laura Keat]]></dc:creator>
            <pubDate>Mon, 22 May 2023 19:12:50 GMT</pubDate>
            <atom:updated>2023-05-22T19:12:50.932Z</atom:updated>
            <content:encoded><![CDATA[<p>The most efficient way to populate a list of data into individual components in react is by mapping through the list and creating a new component for each list item. I wanted to use an accordion to show my list of teachers for React education app I was building. A Bootstrap accordion seemed to be the most effective way to accomplish this.</p><h3>Bootstrap/React Application set up:</h3><p>I started by creating a react application with npx create-react-app education-elevated-accordion I then imported the Bootstrap library into my application by running npm install react-bootstrap bootstrap.</p><p>I then imported the bootstrap node modules and stylings into my index.js file.<br>import &#39;../node_modules/react-bootstrap/dist/react-bootstrap&#39;;<br>import &#39;bootstrap/dist/css/bootstrap.min.css&#39;;</p><p>Lastly, I cleared out the existing code in my App.js file then imported a Container from bootstrap to wrap my code in and added a label to my page to begin. I got the info about how to do this basic set up from a youTube tutorial I watched <a href="https://youtu.be/0SIuH7yHCpA">here</a> via the UiBrains Technologies youTube channel.<br>To check out my set up I ran npm start and it opened my application in a browser at <a href="http://localhost:3000/">http://localhost:3000/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*ru6K96AvZVXdq671eBdq5Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3RATZ3gpPeFL6YKOaf-dRQ.png" /></figure><h3>Application Prep:</h3><p>I needed a list of teacher data to start. I pulled down a teacher object from my final education-elevation application (where this component would live upon completion) and added it to a db.json file in this application. I created a db.json file in the top level of my directory then installed json-server with npm install json-server and tested it by running npx json-server --watch db.json port 8000. I specified the port so that I could check my teachers object out at <a href="http://localhost:8000/teachers">http://localhost:8000/teachers</a> while my react app was running on the default port, port 3000.</p><p>The other thing I did to prep was I created a Teachers component to import into my App.js file. It would only serve the purpose of creating my accordion component then mapping through my teacher list and passing each Teacher into an accordion.item component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vu-RA94PZFk5SEoYsuiYdw.png" /></figure><h3>Accordion Mapping:</h3><p>First I got my list of teachers from my db.json file by running my json-server and using a useEffect hook to fetch the data and store it in state as teachers. I then passed that list of teachers into my Teachers.js component as props.</p><p>In my Teachers.js component I took that list of teachers and mapped through them creating a new component with a file named: TeacherAccordion.js. This component would render each Accordion.Item.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7GzDo0hdhceLh5RNI_PpNg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YTH8AXqUlLHRH8-28rGzng.png" /></figure><p>After being sure to import Accordion from ‘react-boostrap’ my bare bones application was looking great.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NnpvcSwHDQFdcx85ijKdbg.png" /></figure><p>…Except for one problem. It would only display the body for all the teachers or none of the teachers at one time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TE2QJgibVA6sRYbOg6zb7g.png" /></figure><p>I was able to fix this problem by setting the eventKey on the Accordion.Item to equal each teacher.id.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*La9nkJIduHroNMyZ9HGEsw.png" /></figure><p>The end result was a functional accordion list where each list item would display more or less content when the header was clicked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*97DNWzYOtsb3mQCZnSUorQ.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9d686a062df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Action Mailer: A Simple Email Sent]]></title>
            <link>https://laurakeatdev.medium.com/action-mailer-just-an-email-to-start-d406a92731d2?source=rss-b58159e8bcb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/d406a92731d2</guid>
            <dc:creator><![CDATA[Laura Keat]]></dc:creator>
            <pubDate>Sun, 21 May 2023 03:09:02 GMT</pubDate>
            <atom:updated>2023-05-25T19:46:05.313Z</atom:updated>
            <content:encoded><![CDATA[<p>My basic application, Education Elevation, was made for users to donate to school programs of their choosing. Built using Rails/React, I wanted to add a feature that would automate sending an email to my user each time they made a donation. That email would thank them for their donation and inform them of their total donations and their donor tier.<br>Action Mailer was the perfect tool to use. It had clear documentation from Ruby on Rails guides and overall was not challenging to implement. <br><a href="https://guides.rubyonrails.org/action_mailer_basics.html">https://guides.rubyonrails.org/action_mailer_basics.html</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*F1gUegwU8kV7E-oEOdpwvg.gif" /></figure><p>Mailers are very similar to controllers. To kick this off, I started using a generator to create my donation_mailer class in app/mailers along with my donation_mailer views in app/views. I used the command, rails g mailer Donation which generated a donation_mailer.rb that inherited from application_mailer.rb in app/mailers. The generator also created a donation_mailer folder in app/views with demo layouts for text &amp; html.</p><p>With these files all generated in one command the next step was to create an instance method to send the email in my donation_mailer class. Since my donation_mailer class inherited from the application_mailer it automatically had access to these defaults:</p><pre>default from: &quot;from@example.com&quot;<br>  layout &#39;mailer&#39;</pre><p>This method sets default values for all emails sent from this mailer. Moving back into my donation_mailer, I followed the format on rails guides to create a donation_email method. Below you can see the lines of code that I referenced and that I skipped over for simplicity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1p0j-__LwPhPzXypLUFJFw.png" /></figure><p>The default from method was already set in the mailer_controller.rb file so I removed that line. Themail method is used to specify the values of headers on the email and creates the email message. <br>My method looked like this:</p><p>def donation_email<br> @donation = params[:donation]<br>@user = donation.user<br>mail(to: @donation.user.email, subject: &#39;Thank you for your donation!&#39;)<br> end<br>end</p><p>The next step was to create the views for my email. I created a donation_email.html.erb<strong> </strong>file and used the content from the Rails guides to help me draft my email.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L5bRfGi33m3uIaw9jrbEkg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h6nNkLfe_diL7pI1QoHoig.png" /></figure><p>The example above on the left is from the Rails guide and on the right is what I wrote. My donations instances gave access to my user data, so I only needed access to the donation object to access the user that made the donation, info about them and the program the donation went towards.</p><p>The last step to set up my mailer was to call the mailer within the action that with which it was associated. I wanted a thank you email to go out to the user each time a donation was made, so I placed my DonationMailer.with() method inside the create action for donations. <br>The example from the guide, below on the left, was what I tried at first, but couldn’t get the method to be called with a new Donation. I slimmed it down a bit as you can see in my action below on the right. I called on the Class method, .with, and put my donation object at the argument. then called the donation_email method that I wrote in my DonationMailer class with the .deliver_now method for testing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*UWcmRTlfCW8wJE__ojIETg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WGp8OHoGLYASdigRHpAooA.png" /></figure><p>Once this was accomplished my email message was generated on my server when a new instance of a donation was created. Success. Getting that message to end up in an email was the final step.</p><p>I created a test gmail account so I could configure the security settings. To get some help on how to get my gmail account to I referenced this article : <a href="https://noted.lol/setup-gmail-smtp-sending-2023/">https://noted.lol/setup-gmail-smtp-sending-2023/</a></p><p>I had to enable 2-step verification then set an app password to use in my configurations. I used the configuration for gmail almost exactly as it was demonstrated in the rails guide example as you can see below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v5GzmgPyiuUG8iP1XtHBlQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LO7zys7uwp6v5Cphu9V1DQ.png" /></figure><p>In the end my rails action mailer was able to generate an email every time a user makes a donation to a program on my website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F0i3Wpt4XR85tExKHGNACw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d406a92731d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Camping Reservation: Full Stack Ruby on Rails Application- Project]]></title>
            <link>https://laurakeatdev.medium.com/camping-reservation-full-stack-ruby-on-rails-application-project-ea4137e86205?source=rss-b58159e8bcb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea4137e86205</guid>
            <dc:creator><![CDATA[Laura Keat]]></dc:creator>
            <pubDate>Thu, 11 May 2023 01:43:31 GMT</pubDate>
            <atom:updated>2023-05-11T01:43:31.882Z</atom:updated>
            <content:encoded><![CDATA[<p>Notes</p><p>The goal of this project was to create an application where a user can log in to search for campsites. My user should be able to select a campsite to create a reservation for then be able to update or delete that reservation from their account without effecting the campsite itself.</p><p>I also wanted a user with admin status to be able to create and delete campsites. For any reservations associated with a campsite that is being deleted to also be deleted.</p><p><strong>My expected deliverables for my user were:</strong></p><ul><li>can create an account or log in securely</li><li>can view a list of campsites</li><li>can click on a campsite to create a reservation</li><li>can view a list of their reservations</li><li>ability to change the dates of an existing reservation</li><li>can delete any reservation that they had previously made</li></ul><p><strong>The deliverables for my admin were the same but also included:</strong></p><ul><li>can add a campsite to the campsites list</li><li>can delete a campsite from the campsites list</li></ul><p>I began by drawing a diagram of the three tables I would store in my database. A campers table, a reservations table and a campsites table. <br>With my application a camper can have many reservations and therefore have many campsites. A campsite can also have many reservations and therefore many campers. My reservations each belong to a single camper and a campsite.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uHX4RZP3fkL-EYq4fnxvfQ.png" /><figcaption>Camper, reservation, campsite model relationships diagram.</figcaption></figure><p>I built out my three models with their associated controllers, serializers and routes by running the command</p><pre>rails g resource &lt;modelname&gt; &lt;attribute_name:attribute_data_type&gt;</pre><p>I really enjoyed the ease of rails generators so I could cover most my needs for each table in one line of code. I had to remember to put my foreign keys into my reservations (join) table.</p><pre>rails g resource reservation start_date:date end_date:date camper_id:belongs_to campsite_id:belongs_to</pre><p>I made a mistake the first time by using the wrong datatype for the start and end dates on a reservation. I made them datetime datatypes which meant that each date included more information than I cared for. So I ran a migration to change the column datatype to just “date”.</p><p>Building out this project was harder for me than the other projects that I’ve built so far. One of the areas that I had trouble was understanding how to authenticate and authorize. I had the simple idea down, that authentication is about verifying a user’s identity, while authorization is about determining what actions a user is allowed to perform based on their identity and role.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*gkEPWncGiQ0GkYoLaDkcSQ.gif" /></figure><p>Ruby on Rails makes authentication pretty easy by using the ‘bcrypt’ gem and calling the has_secure_password method in the User model. It’s important to have a password_digest column in the user table, which is the camper table in my application.</p><pre>class User<br>  has_secure_password<br><br>  #table relationships<br>  #validations<br>end</pre><p>My users could sign up for a new account as a camper via the camper route directing into my camper controller. The create action defined there made sure that the correct params were being sent through via params.permit and I set my session hash to that current user so that my user could stay logged in even when new requests get sent to the server.</p><p>A sessions controller also made it possible to store a user in the sessions hash with the log in method I stored there as a create action. The other method in my sessions controller was a destroy action to log my user/camper out of their session so that no one would make a new campsite reservation in their name.</p><p>I decided to add an extra layer of authorization to my account by not only making sure only stored campers could access campsite information and their reservations, but I added an admin feature to add &amp; delete campsites. This required the use of authorization. Once again, authorization is the process of determining what access a user has to interact with data and the database depending on their identity and role.</p><p>I wrote my authorization helper methods in my application controller so that they would be inherited in camper and admin_form controllers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7YWSokj7NDcNnTB_apg4Bg.png" /></figure><p>My two helper methods were :authorize and :admin. The authorize method set an instance variable to the value of my current, logged in user/camper. The admin method made sure that the user was both logged in and an admin.</p><p>I called these methods as a before_action in the admin_form and reservations_form controllers. This makes sure that before a general camper makes a reservation or edits an existing reservation they are logged in and they are the user that is associated with that reservation. It additionally makes sure that only campers that have a truthy is_admin status can update the campsites themselves. The add and delete campsite routes are only accessible after the admin method has been called.</p><p>Building this application definitely was a challenge for me. I hope to continue working on it and adding styles and better validations. I intend to validate the dates of reservations so that a campsite doesn’t accidentally have two reservations on the same date.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea4137e86205" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dance Festival Planner- Full Stack SPA]]></title>
            <link>https://laurakeatdev.medium.com/dance-festival-planner-full-stack-spa-f999f8c651fb?source=rss-b58159e8bcb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/f999f8c651fb</guid>
            <dc:creator><![CDATA[Laura Keat]]></dc:creator>
            <pubDate>Mon, 13 Feb 2023 06:20:51 GMT</pubDate>
            <atom:updated>2023-02-13T18:53:28.009Z</atom:updated>
            <content:encoded><![CDATA[<p>My first full stack application is completed and already helpful. Using Sinatra and Active Record for my database and React for my frontend, I learned a lot while building this.</p><p>My application is a single page app that displays dance festivals that I would like to attend. I have a database table with a list of locations where dance events occur and a table with the dance events and their necessary values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-wxTwLz7XG6dHforWpmkNw.png" /></figure><h3>Class Method to Calculate Affordability</h3><p>The attributes that my event table has are: name, start date, location (foreign key), style, price and affordability. One of the unique features I built is an instance method to find and display each events’ affordability. The price will be put into the event upon creation and my event model has a method to calculate whether an event is affordable. This method determines that an event is indeed affordable if it’s under $200. If it’s more than $200 then the event’s affordability is saved as false.</p><p>This method is called when I get my events to make sure that each event accurately displays its affordability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dKWZS8ygh-bGCXNGcrSTaw.png" /></figure><p>At first I got stuck creating this because I couldn’t remember where I should call this method. I tried to call it in my seed file but I did not have access to it there. I tried to require my Event class file, but it still did not work. Once I called the method (and saved the result) in my get request it worked beautifully.</p><h3>Separating Concerns</h3><p>Another difficulty I had was making sure that when I added an event, it updated the event, the event’s location, but did *not* update the locations in the database. I want to keep my list of locations the same unless I add a new one. I tried creating an extra fetch request on my front end to update the event and the location. This was problematic because it updated the actual location row in my location table. I simply needed to update that specific event’s location with its id.</p><p>I wanted to easily access the location associated with a dance event by either its name or id. In order to do this I had to include the location in my get requests (for both the list of events and a single event). This way, on the client side, I could simply list the location names associated with each event when my page rendered and in my single fetch request to list the events. I wanted to skip the step of also fetching my locations list. I would have had to find the match between the foreign key in each event hash with the id for the connected location. It was much less code and less processing to use a single fetch request and include all the desired location information with each event.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FGJQmxr_HgvJ2dH8RVGKcA.png" /></figure><h3>Cluttered Form</h3><p>I needed a form to add a new dance event and I needed a form to update my dance event. To keep my code DRY (do not repeat yourself) I figured there would be a way to use a generic event form and write formulas to differentiate between submitting with a “get” request to my database or with a “put” request. <br> To start, I made a list of what each function would need to do. I would need a formula to add and a formula to update. Both formulas would take a parameter of the form values and both would need to make a fetch request. In the end they were not that different from each other. <br> Since my link to add an event did not have any parameters, and my link to update an event used parameters to populate the form with the selected event’s values, I chose to use a short “if, else” conditional to find out if the parameters were empty therefore calling the add function or otherwise calling the update function with the parameters in the url so that it would update that specific event. <br> This worked and wasn’t very complicated at all, despite my concerns before white-boarding the process. However, I ended up with a lot of functions on my form. I had my useEffect hook to get my list of locations and set it to my state. I needed this list to populate my dropdown menu so that my user would not create a new location by accident. (I only wanted to create locations that would post into my locations table in my database.) I had my necessary form functions to change the state with each click (onChange) and my function to create a single object with my form values and location value and then submit it with (onSubmit). In addition to those I had my add event and update event functions. <strong>This felt cluttered to me.</strong></p><p>My programmer friend, Todd, worked with me to debug another issue and he suggested I create a services folder with a form service file to store my helper functions. I love this because it meant that my form file only showed the necessary functions for the form. I still kept those functions on my form because I felt that they were helpful to see to understand what was happening within the form component. I realized I could refactor my submit function to handle both those fetch requests (post and put) and considered it. In the end I decided that keeping those two functions separate makes my code easier to read and understand what each function is doing. I made comments in the form to make it easy to understand what the helper functions were doing and where to find them easily.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f999f8c651fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Student Project]]></title>
            <link>https://laurakeatdev.medium.com/react-student-project-famigistry-653984e652bb?source=rss-b58159e8bcb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/653984e652bb</guid>
            <dc:creator><![CDATA[Laura Keat]]></dc:creator>
            <pubDate>Thu, 28 Oct 2021 20:12:30 GMT</pubDate>
            <atom:updated>2021-11-02T22:00:10.783Z</atom:updated>
            <content:encoded><![CDATA[<p>For my second project with Flatiron, I wanted to spend a little more time learning to use CSS Grids &amp; Flexbox to get my layout to sit better and be more responsive to different browser window sizes.</p><p>You can check out my video walk-through here if you’d like!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FbSUEDknhNZQ%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DbSUEDknhNZQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FbSUEDknhNZQ%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b1903c674da7a29b465d33672fac444/href">https://medium.com/media/8b1903c674da7a29b465d33672fac444/href</a></iframe><p>The main issues I had working with React routes was to make sure that I had the necessary state placed in the right component.</p><p>Initially I had my member’s list load from the App.js page with a useEffect hook to pull that list from my database as soon as the page is loaded. At first that worked well. I set up a filter function in there to filter the members displayed so that my users could easily search for a specific user. The problem was that once that list was filtered if my user navigated to another page with my route links then came back to the members page, it was still displaying the filtered member list.</p><p>In the end I realized that I could move that state into my Members component and filter those members there. This way each time that page was navigated to it would re-mount that component and I would have a full list of members.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*SDgWWv1G5eInu4IBdBOtDQ.png" /></figure><p>I hit another issue because I did not stop one of my form’s from refreshing the page upon submit. This TypeError I had was from trying to use a useHistory hook to redirect the page after the form was submitted, but useHistory and the page refresh were running asynchronously and every other time I would get an error when it the useHistory happened first. I finally figured out what was going on through some debugging help from a friend and added back an event.preventDefault() method on the submit handler and the world became a better place again. Phew!</p><p>Going forward I’d like to add a way for users to log in so that only the user can add or remove items from their wishlist. I think it would also be great for a user to specify priority on an item in their wishlist. That way other users can sort a friend’s wishlist in order of importance.</p><p>In the end I got really familiar with component organization in react. I experienced how important it is make sure my state is well placed so that it can be accessed everywhere necessary!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*w8hKJtGTrp3FsAVFvVwAVg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=653984e652bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>