<?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 Nathan F. on Medium]]></title>
        <description><![CDATA[Stories by Nathan F. on Medium]]></description>
        <link>https://medium.com/@nathanfoss.dev?source=rss-e78c908424e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8x4kd67EX6BNKezJURd_7g.jpeg</url>
            <title>Stories by Nathan F. on Medium</title>
            <link>https://medium.com/@nathanfoss.dev?source=rss-e78c908424e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 08:18:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nathanfoss.dev/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[useEffect: re-rendering components vs. refreshing the browser tab explained]]></title>
            <link>https://medium.com/@nathanfoss.dev/useeffect-re-rendering-components-vs-refreshing-the-browser-tab-explained-d031e5c6fce2?source=rss-e78c908424e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d031e5c6fce2</guid>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Nathan F.]]></dc:creator>
            <pubDate>Thu, 05 Jan 2023 17:16:50 GMT</pubDate>
            <atom:updated>2023-01-05T17:16:50.921Z</atom:updated>
            <content:encoded><![CDATA[<p>In the context of React, “side effects” refers to anything that is performed outside of the component rendering cycle, like fetching data or directly modifying the DOM. These types of operations are called side effects because they can have an impact on other parts of the app as a whole, not just in the component that is being rendered.</p><p>Therefore, anything that happens inside the useEffect is a side effect. What does that mean? It means that if we try to change a useState variable inside a useEffect for a fetch, we can’t use that changed state variable — only in the return like this:</p><pre>return (<br>    &lt;div&gt;<br>         {<br>            projectData.map(eachObj =&gt; {<br>              console.log(eachObj)<br>            })<br>         }<br>    &lt;/div&gt;</pre><p><strong>projectData</strong> is our useState variable that was used to store the fetched data. We can use it inside the return because this code only runs after the component rerenders.</p><p>Cleaning up side effects is an important step in using the useEffect . When a component stops rendering, like due to a <strong>child.remove(), </strong>it is important to clean up any side effects that have been created.</p><p>To clean up side effects with the useEffect hook, you simply need to return a function from the effect that will be called when the component is unmounted. This function can be used to clean up any side effects that have been created. A component is unmounted when it is removed from the DOM. This can happen when a component is no longer needed, such as when a user navigates to a different page or when a component’s props change in such a way that it is no longer rendered.</p><p>Here is an example of a component that is unmounted when a user navigates away from a page:</p><pre>import { useEffect } from &#39;react&#39;;<br>import { useHistory } from &#39;react-router-dom&#39;;<br><br>function MyComponent() {<br>  const history = useHistory();<br><br>  useEffect(() =&gt; {<br>    return () =&gt; {<br>      // component will be unmounted when the user navigates away from the page<br>    };<br>  }, []);<br><br>  const handleClick = () =&gt; {<br>    history.push(&#39;/other-page&#39;);<br>  };<br><br>  return (<br>    &lt;div&gt;<br>      &lt;button onClick={handleClick}&gt;Go to other page&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>Refreshing the browser tab vs. Re-rendering the component the page is the difference between starting the app from zero vs. starting the app from where the component last left off.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d031e5c6fce2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Developing a Google Chrome Extension]]></title>
            <link>https://medium.com/@nathanfoss.dev/developing-a-google-chrome-extension-6950c8e99252?source=rss-e78c908424e------2</link>
            <guid isPermaLink="false">https://medium.com/p/6950c8e99252</guid>
            <category><![CDATA[passive-income]]></category>
            <dc:creator><![CDATA[Nathan F.]]></dc:creator>
            <pubDate>Wed, 14 Dec 2022 15:36:41 GMT</pubDate>
            <atom:updated>2022-12-15T20:57:27.092Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*yOARNeMA_MgfyDw1.jpg" /></figure><p>Google Chrome is one of the most popular web browsers in use today, and part of what makes it so versatile is the ability to add extensions. One of the most useful extensions is the AdBlocker. This can not only improve the speed and performance of the browser, but it can also improve the user’s overall browsing experience by reducing the amount of clutter on a webpage. This app, used by over 200 thousand of people, <a href="https://www.youtube.com/watch?v=UZQqidPMu6k&amp;t=149s&amp;ab_channel=MyFirstMillion">was originally made by one single person</a>. AdBlocker is free to use but there are also many useful apps that charge a subscription service, allowing the developer to make huge profits every month. To make an app like this, it only takes a small knowledge of how to use HTML/CSS and JavaScript. Or even as an experienced developer, you can make complex extensions using frameworks like React, Vite, Vue, or with other languages like TypeScript. Whichever path you come from, this blog will show you the steps to get started.</p><p>Once you have an idea for your app, it’s time to start building your extension. To do this, you’ll need to create a new folder on your computer and give it a name that reflects the purpose of your extension. Inside this folder, you’ll need to create a few key files:</p><ul><li>manifest.json: This is the main file that is required for any and all chrome extension apps. All other files in your app will be optional, depending on what kind of app you are trying to make. The manifest.json is used to define the basic information about your extension, such as its name, description, and version number. This would look something like this —</li></ul><pre>{<br>    &quot;name&quot;: &quot;Khanya&#39;s Google Chrome Extension&quot;,<br>    &quot;version&quot;: &quot;0.1&quot;,<br>    &quot;description&quot;: &quot;Makes hogs fly&quot;,<br>    &quot;manifest_version&quot;: 3,<br>    &quot;action&quot;: {<br>        &quot;default_popup&quot;:  &quot;demo.html&quot;,<br>        &quot;default_icon&quot;: &quot;your-image.png&quot;<br>    }<br>}</pre><ul><li>background.js: This file will contain the core logic for your extension. It will run in the background and handle any tasks that need to be performed automatically, such as updating the extension&#39;s icon, manipulating what the user sees on their webpage or communicating with other parts of the web. This file could be as easy and simple, or as complex and profound as you want, depending on your app.</li><li>popup.html: This file defines the user interface for your extension. When the user clicks on their extension icon, an interface you built will show up like this —</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iOhMtsnc6ftAkF7W.png" /></figure><ul><li>popup.js: This file will contain the JavaScript code that powers your extension&#39;s user interface. It will handle events such as button clicks and respond to user input.</li></ul><p>As you develop your app, you can test if it is working through the Google Chrome Developer dashboard. Google charges their developers a <a href="https://developer.chrome.com/docs/webstore/register/">one time fee of $5</a> that allows you to publish as many apps as you want. After paying the fee, click on your extension icon(the puzzle piece) in the top right corner of chrome, then click on <strong>Manage Extensions</strong>. In the Dashboard, you’ll want to turn on Developer mode(top right of page).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/0*3bYDrFc6YQlIgmcH" /></figure><p>Inside this dashboard, you can toggle all your extensions on or off, test for errors in your code, and manage your extension. You’ll click on <strong>load unpacked </strong>to upload your extension to Google from your computer.</p><p>Finally, you can publish your app on the <a href="https://chrome.google.com/webstore/category/extensions?hl=en">Chrome Webstore</a>. There, you can choose if your app will be free to use or a paid service. Also, the marketing of your app can be done there — a picture of your app’s functionality or even a demo video. You can also link your Github, website, or other contact info there. After publishing, you can see the ratings, number of downloads, and statistics of your app.</p><p>That’s it! You are a Google Developer.</p><p>For more information about the development process and details, Google has a documentation guide for developers, made by developers.</p><p><a href="https://developer.chrome.com/docs/extensions/">— Google Developer Guide —</a></p><p><a href="https://crxjs.dev/vite-plugin/">— Additional Guide from the Official Docs team —</a></p><p><a href="https://github.com/dutiyesh/chrome-extension-cli">— React Plugin to Immediately get you up and running —</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6950c8e99252" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux Commands (Gone WRONG?) *must read*]]></title>
            <link>https://medium.com/@nathanfoss.dev/linux-commands-gone-wrong-must-read-49f41bae3219?source=rss-e78c908424e------2</link>
            <guid isPermaLink="false">https://medium.com/p/49f41bae3219</guid>
            <dc:creator><![CDATA[Nathan F.]]></dc:creator>
            <pubDate>Thu, 08 Dec 2022 14:48:55 GMT</pubDate>
            <atom:updated>2022-12-08T14:48:55.220Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lKII7_yk3RzfUSF2XpHloA.png" /></figure><p>Linux is an open source operating system written by a single person, Linus Torvalds, in 1991. Linux was a personal project for his own use so he could more easily work on his code. But after hearing from a friend that his work could be further improved with others as an open source project, Linux was published and is now used by millions of computers around the world. Linux is derived from UNIX which is what MAC OS and Ubuntu also derive from so all three have similarities. Now we can use Linux OS for our own personal use.</p><p>Interview with Linus Trovald’s on TED Talk:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fo8NPllzkFhE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Do8NPllzkFhE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fo8NPllzkFhE%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7de8a0469fc96322edbb648b521080b6/href">https://medium.com/media/7de8a0469fc96322edbb648b521080b6/href</a></iframe><p>Every developer should know how to use the man command.</p><p>The command “man” short for manual is what we put before any command that we want to know more about. This is our catalog of options we can use to better move through our files.</p><ol><li>Call man on itself.</li></ol><pre>man man</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WLYPx0NitCTH8WQtyAoJaw.png" /></figure><p><strong>man man</strong> pulls up the manual of how to use the manual.</p><p>The <em>most important</em> from this page is <strong>q</strong> for quit. If you press q, this quits the man command and brings you back to the prompt.</p><p>To go back into the manual we type <strong>man man</strong> again. To move through the manual we can use the mouse scroll, or up and down arrow keys. To cycle through the manual by page, <strong>space bar</strong> for the next page, and <strong>b</strong> for the previous page. To search for a specific word on the page, we type “<strong>/” </strong>then type whatever word you want to search for in the prompt. <strong>n</strong> to cycle through all matches or <strong>shift+n </strong>to cycle back through the matches.</p><p>That’s it! That’s how you use man.</p><p>Now some useful linux commands(capitalization does matter):</p><pre>ls -G</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1wTHN8z-_HgLGSY8HqIDXw.png" /></figure><p><strong>ls -G</strong> highlights any directors/folders in our current directory and leaves the files white.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hEinLLNTEoduxwJi6YCZkg.png" /></figure><p>running <strong>ls -F</strong> adds a “/” forward slash on the directors in our current directory.</p><p>We can also stack commands on top of each other(order usually doesn’t matter) .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IzbbQZakUVmMYgNfwITdGA.png" /></figure><p><strong>ls -G -F</strong> will do both commands at the same time.</p><p>If you’ve been using Github to manage your project, linux also gives a way to see a record of all your changes.</p><p>Type <strong>git log</strong> in your terminal to see a record of every commit you’ve made and in what branch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*abdix8D8M0IhKF_EtUIXyg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49f41bae3219" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Object Oriented Programming in JavaScript]]></title>
            <link>https://medium.com/@nathanfoss.dev/object-oriented-programming-in-javascript-19aa7cf53a95?source=rss-e78c908424e------2</link>
            <guid isPermaLink="false">https://medium.com/p/19aa7cf53a95</guid>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Nathan F.]]></dc:creator>
            <pubDate>Wed, 23 Nov 2022 15:00:22 GMT</pubDate>
            <atom:updated>2022-11-23T15:00:22.964Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IiusMPCXIaAoquPZqalCLg.png" /></figure><p>Before Object Oriented Programming came along, there was Procedural Programming. In Procedural Programming we have some functions to handle DOM manipulation, some functions handle server communication, and other functions may serve as helper functions to others — dividing a program into a set of functions. Data is stored in various variables and functions that are invoked using the data. This style of programming is how many developers start learning to code and, as we keep learning, we realize that the more complicated our code gets, the harder it is to understand and change it. When the program is larger with many interconnecting functions and dry code, changing one function can break code in another child or depending function. It becomes increasingly difficult to follow the flow your code as you build more.</p><p>Object Oriented Programming came to save the day. In Object Oriented Programming we combine a group of related variables and functions into a unit — which we call Encapsulation.</p><p>A Person in Procedural Programming-</p><pre>let name = &#39;Adam La Rosa&#39;;<br>let age = 15;<br><br>function sayHello(nameOfPerson) {<br>  console.log(`Hello, my name is ${nameOfPerson}.`);<br>}<br><br>function sayAge(age) {<br>  console.log(`I am ${age} years old.`);<br>}<br>sayHello(name);<br>sayAge(age);</pre><p>A Person in Object Oriented Programming -</p><pre>class Person {<br>  constructor(name, age) {<br>    this.name = name;<br>    this.age = age;<br>  }<br>  sayHello() {<br>    console.log(`Hello, my name is ${this.name}.`);<br>  }<br><br>  sayAge() {<br>    console.log(`I am ${this.age} years old.`);<br>  }<br>}<br>let adam = new Person(&#39;Adam La Rosa&#39;, 15);<br><br>adam.sayHello();<br>adam.sayAge();</pre><p>The End Results of both styles are the same, but the data is more structured in the second way because it’s all in one place and easier to change.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19aa7cf53a95" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[insertAdjacentElement in JavaScript]]></title>
            <link>https://medium.com/@nathanfoss.dev/insertadjacentelement-in-javascript-af989ce897c?source=rss-e78c908424e------2</link>
            <guid isPermaLink="false">https://medium.com/p/af989ce897c</guid>
            <dc:creator><![CDATA[Nathan F.]]></dc:creator>
            <pubDate>Mon, 14 Nov 2022 04:40:53 GMT</pubDate>
            <atom:updated>2022-11-14T04:40:53.700Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*FPhDWuOKE4JR662ZPANi9Q.jpeg" /></figure><p>As software developers, we traditionally take our first steps into DOM manipulation utilizing the append or appendChild methods. These methods allow us to dynamically add content to the bottom of an element on the webpage — Church! But what if we need to add content <em>not</em> at the bottom?</p><p>Consider append syntax:</p><pre>const main = document.querySelector(&#39;div&#39;);<br>const h1 = document.querySelector(&#39;h1&#39;);//h1 is already inside the main<br>const content = document.createElement(&#39;p&#39;);<br>main.append(content);<br></pre><p>In this example, our content is going to be added after h1 because h1 is already inside the main div element.</p><p>Now what if there was already an h2 element after the h1, but we still want to add our content directly after h1?(Between h1 and h2)</p><p>Here is the juicy insertAdjacentElement solution:</p><pre>const main = document.querySelector(&#39;div&#39;);<br>//h1 and h2 are already inside the main div<br>const h1 = document.querySelector(&#39;h1&#39;); <br>const h2 = document.querySelector(&#39;h2&#39;);<br><br>const content = document.createElement(&#39;p&#39;);<br>h1.insertAdjacentElement(&quot;afterend&quot;, content);<br></pre><p>The result of our solution would sandwich our content between the h1 and h2 elements. We said, “Hey content, look at h1. Go after the end of h1.” Notice that the location has to be in quotes.</p><p>We can also send content to locations: beforebegin, afterbegin, beforeend, and back to afterend.</p><p>Be aware that if we use locations “afterbegin” or “beforeend”, the content will be placed <em>inside</em> of the element. In other words, if we put content “afterbegin” on the h1, the content will be placed before whatever text is already inside the h1. ex: “Hello World” =&gt; “content Hello World”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af989ce897c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>