<?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: Carmen Salas</title>
    <description>The latest articles on Forem by Carmen Salas (@cs_carms).</description>
    <link>https://forem.com/cs_carms</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%2F295965%2Fcd9dbafd-3f56-440c-bf5d-4ea0b51e6a3f.jpeg</url>
      <title>Forem: Carmen Salas</title>
      <link>https://forem.com/cs_carms</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/cs_carms"/>
    <language>en</language>
    <item>
      <title>Getting into Gatsby</title>
      <dc:creator>Carmen Salas</dc:creator>
      <pubDate>Mon, 20 Jul 2020 17:49:32 +0000</pubDate>
      <link>https://forem.com/cs_carms/what-is-gatsby-4lgj</link>
      <guid>https://forem.com/cs_carms/what-is-gatsby-4lgj</guid>
      <description>&lt;p&gt;Gatbsy is a very popular framework used to create static webpages. In this blog, we'll discuss what kind of tool Gatbsy is and why is it so helpful in building webpages that follow a &lt;a href="https://dev.to/carmensalas14/jamstack-approach-39m"&gt;JAMstack&lt;/a&gt; approach.&lt;/p&gt;

&lt;p&gt;We will be going over: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;What is Gatsby?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is GraphQL?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How to get started using Gatsby?&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What is Gatsby?
&lt;/h3&gt;

&lt;p&gt;The common definition for Gatsby is, it is a static site generator. But let’s discuss what this means. &lt;br&gt;
This means Gatsby is a tool that will help us produce static sites using HTML, JS, CSS, images, and other static content, that we can then load onto a server. Which is a more JAMstack approach to building applications. &lt;br&gt;
The traditional approach of server-side rendered applications is that that when you request a page on the application, generally it will then have to reach a database to retrieve the data and then build the page in real-time on the server to then send make to the client. With Gatsby, a JAMstack approach is taken to serving a website. Gatsby will create the pages ahead of time which is then served and the client is only requesting the static pages created. More specifically, Gatsby calls the endpoint with GraphQL, which fetches the data you need, and then a static page is created with that data. The data is only queried once and then served on to a server as a static HTML file. &lt;br&gt;
Gatsby uses graphQL to query data from an external data source such as markdown files, JSON files, a database, or even an API. Gatsby includes plugin architecture, which allows us to load JavaScript, make API calls, add animations, build interactions onto the HTML files which allows us to still have very dynamic websites. Gatbsy also uses React for templating and CSS for styling. &lt;/p&gt;

&lt;h3&gt;
  
  
  What is GraphQL?
&lt;/h3&gt;

&lt;p&gt;GraphQL is a querying language that allows you to query for data by describing the data you want to receive from a data source such as a markdown file. You are then given the data in the way that you asked for it&lt;/p&gt;

&lt;h3&gt;
  
  
  How to get started using Gatsby?
&lt;/h3&gt;

&lt;p&gt;Gatbsy uses Node, so Node will need to be running on a development environment on your computer. You will need to have installed Node and Git before installing Gatsby. You start off by installing Gatsby on your local machine globally. You then run Gatsby on your computer, by creating a new Gatsby template and it will help you set up your application to generate static pages for you. The Gatsby &lt;a href="https://www.gatsbyjs.org/docs/" rel="noopener noreferrer"&gt;documentation&lt;/a&gt; explains thoroughly how to get started with building sites on Gatsby from &lt;a href="https://www.gatsbyjs.org/docs/quick-start" rel="noopener noreferrer"&gt;quickstarts&lt;/a&gt; for experienced developers who are ready to jump in, to &lt;a href="https://www.gatsbyjs.org/tutorial/part-zero/" rel="noopener noreferrer"&gt;step-by-step tutorials&lt;/a&gt; for beginners starting from anywhere. &lt;/p&gt;

</description>
      <category>node</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
    <item>
      <title>This is my JAMstack</title>
      <dc:creator>Carmen Salas</dc:creator>
      <pubDate>Mon, 13 Jul 2020 19:55:15 +0000</pubDate>
      <link>https://forem.com/cs_carms/jamstack-approach-39m</link>
      <guid>https://forem.com/cs_carms/jamstack-approach-39m</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;What is JAMstack?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Let’s talk about an approach to building applications that may be more frontend developer-friendly. JAMstack is a concept or approach for building out applications if you want to create a website that does not require creating a server or database. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What is the JAMstack approach?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;JAMstack stands for JavaScript, API, Markup. Typically when building out an application most developers are used to a Mololithinc structure. In a monolithic structure, the front end is tightly coupled with the backend. When the client makes a request, it hits a server, which pulls data from a database, that then produces HTML to render and then sends that back to the client. There is no need to build out the HTML page for every page request the client makes in the JAMstack structure. &lt;/p&gt;

&lt;p&gt;The main concept behind JAMstack is to decouple the frontend from the backend and free the frontend from servers sp that it can be deployed directly to a CDN&lt;br&gt;
With a JAMstack approach, the frontend pages are built before it is sent to the client through a build process before being deployed. &lt;br&gt;
The JavaScript is the request/response cycle on the client’s side. &lt;br&gt;
The M in JAMstack stands for Markup. The markup are the static pages that are prebuilt and they are put in a CDN. So, if the client requests a page, there is no need to hit a server to build out the HTML, it instead will fetch the HTML from a CDN which has been pre-built. &lt;br&gt;
The A in JAMstack is for the use of third party APIs which provide the dynamic content to the page. As well as querying requests to an API from the frontend before the pages are built to then deploy. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;So, what are the benefits of using the JAMstack approach?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;There are lots of benefits to this approach to building an application.&lt;br&gt;
The first is that your website will be faster since it does not have to hit a server and the pages are prebuilt. Typically when you host your applications on servers with databases, users are making requests to the same servers in limited locations, which can cause traffic jams (pun intended). Instead, in JAMstack, you are deploying an application globally through the use of CDNs. A &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/CDN" rel="noopener noreferrer"&gt;CDN (Content Delivery Network)&lt;/a&gt; distributes the static content, like the static content built in a JAMstack approach and then serves them to the users in a location closer to them. This also means higher security since there are no servers or databases in your application that are at risk. Because your pages are pre-built the performance of your application skyrockets as well.&lt;br&gt;&lt;br&gt;
Lastly, this makes the process of developing a site much easier, since there is no need to manage and build servers or databases. You can manage the content of your page through version control such as GIT. This approach to building an application makes sense if you have an application that does not require a full database and has content that can be built beforehand using markup.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cover by &lt;a href="https://unsplash.com/@markusspiske" rel="noopener noreferrer"&gt;Markus Spiske&lt;/a&gt; on Unsplash.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>html</category>
      <category>devops</category>
    </item>
    <item>
      <title>How to be an A11y</title>
      <dc:creator>Carmen Salas</dc:creator>
      <pubDate>Thu, 09 Jul 2020 19:38:15 +0000</pubDate>
      <link>https://forem.com/cs_carms/how-to-be-an-a11y-4gcl</link>
      <guid>https://forem.com/cs_carms/how-to-be-an-a11y-4gcl</guid>
      <description>&lt;p&gt;In my previous &lt;a href="https://dev.to/carmensalas14/accessibility-in-applications-23p1"&gt;blog&lt;/a&gt;, I talked about why it is important that we follow the Web Content Accessibility Guidelines.&lt;br&gt;
In this blog, I’m going to go over the first steps we can take to make our applications more accessible and implementing what  WCAG recommends. &lt;/p&gt;

&lt;p&gt;We will be going over:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Writing Semantic HTML&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Introduction to ARIA&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;Writing Semantic HTML&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;First, we will talk about semantics and writing semantic HTML. &lt;br&gt;
Semantics in HTML means that if we are using a semantic element in HTML we expect the element to give us information and what to expect inside of it. It is the idea that every element in your document has a purpose. This is important so that say if a user is using assistive technology like a screen reader to navigate your application, they can easily interpret what every element on the page is doing/saying. &lt;br&gt;
An example of writing HTML that is more semantic is using &lt;code&gt;h&lt;/code&gt; to represent important and less important heading on your page. Splitting up the HTML on your page to use &lt;code&gt;main&lt;/code&gt;, &lt;code&gt;article&lt;/code&gt;, and &lt;code&gt;footer&lt;/code&gt; tags can be helpful.&lt;br&gt;
A good example of an element often used that is not very semantic is the &lt;code&gt;div&lt;/code&gt; tag. The &lt;code&gt;div&lt;/code&gt; tag semantically is a grouping of content, it is often read as a ‘group’ by assistive technology. So, if there is something important in your div such as a list, button, or any important content, you want to use an element that is more semantic. You can also use ARIA to make elements more semantic, we’ll go into that next.&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Element&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;Introduction to ARIA&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Next, we will go into ARIA.&lt;br&gt;
ARIA stands for Accessible Rich Internet Applications, and it helps with making non-accessible controls accessible. For cases where you are using DOM elements that are not semantic, ARIA HTML attributes can help add a semantic layer to elements to make them readable from assistive technologies. ARIA attributes modify the way an element is translated to the &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/AOM#:~:text=The%20accessibility%20tree%2C%20or%20accessibility,%2C%20attributes%2C%20and%20text%20nodes." rel="noopener noreferrer"&gt;accessibility tree&lt;/a&gt;. This is the only change ARIA makes to the element. It will not make any changes to how the element behaves on the page. &lt;/p&gt;

&lt;p&gt;Here is an example of a way we would write an input semantically.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;lable&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;radio&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nx"&gt;Option&lt;/span&gt; &lt;span class="nx"&gt;One&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A screen reader would be able to provide to the user the label which in this case is “Option One” and it would also tell us the state of the radio input, whether it was selected or not. &lt;/p&gt;

&lt;p&gt;Here is an example in which we are not able to use semantic in order to display a radio input.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="nx"&gt;radio&lt;/span&gt; &lt;span class="nx"&gt;checked&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nx"&gt;Option&lt;/span&gt; &lt;span class="nx"&gt;One&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So here we know that this div is meant to be a radio input with a state of checked because we added classes that represent this to us. However, a screen reader would not be able to read this information because divs do not have roles or states to indicate this in the accessibility tree. &lt;/p&gt;

&lt;p&gt;Here is how we can use ARIA attributes to make this div tag more semantic.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="nx"&gt;radio&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt; &lt;span class="nx"&gt;role&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="nx"&gt;radio&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt; &lt;span class="nx"&gt;aria&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;checked&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nx"&gt;Option&lt;/span&gt; &lt;span class="nx"&gt;One&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By adding this &lt;code&gt;role&lt;/code&gt; and &lt;code&gt;aria-checked&lt;/code&gt; attribute causes our element to now to have a role and state in the accessibility tree, which assistive technologies can now pick up and translate to the user. It will not change anything about the elements’ visual appearance or behavior on the page. &lt;/p&gt;

&lt;p&gt;You can learn more about ARIA (&lt;a href="https://www.w3.org/WAI/standards-guidelines/aria/" rel="noopener noreferrer"&gt;Web Accessibility Initiative - Accessible Rich Internet Applications&lt;/a&gt;) authoring practices for implementing ARIA attributes to less semantic HTML elements. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cover by The Creative Exchange on Unsplash.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>html</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
    <item>
      <title>All Things A11y</title>
      <dc:creator>Carmen Salas</dc:creator>
      <pubDate>Mon, 06 Jul 2020 19:33:39 +0000</pubDate>
      <link>https://forem.com/cs_carms/accessibility-in-applications-23p1</link>
      <guid>https://forem.com/cs_carms/accessibility-in-applications-23p1</guid>
      <description>&lt;p&gt;Accessibility is an extremely important and necessary aspect of building web applications, and unfortunately oftentimes overlooked. I want to provide a beginner’s guide to what accessibility on the web is and how everyday developers like you and I can make our applications accessible to anybody!&lt;/p&gt;

&lt;p&gt;We’ll be going over:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;What are the Web Content Accessibility Guidelines&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Who are the Web Content Accessibility Guidelines for?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are the main principles of the Web Content Accessibility Guidelines?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How you can begin to implement accessibility into your applications?&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What are the Web Content Accessibility Guidelines&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If you have ever looked into accessibility in applications you probably heard of the Web Content Accessibility Guidelines. These guidelines are provided by the Web Accessibility Initiative (WAI) of the World Wide Web Consortium (W3C). W3C is the main international standards organization for the internet and provides standards to help make the web accessible which are recognized by governments and businesses internationally. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Who are the Web Content Accessibility Guidelines for?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The WCAG is intended for developers. It is not only for large cooperations and governments to follow in order to make their products accessible to all bodies but also for individual developers because they are to provide web access to all users. This is extremely important, as a developer, we don’t anyone to left out in using our products and we should always strive to make products and applications that anyone can use. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What are the main principles of the Web Content Accessibility Guidelines?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;There are two versions of WCAG created by W3C WCAG 2.0 and WCAG 2.1. They are both stable referencable technical standards for web accessibility. They both have 12-13 guidelines, that are categorized into &lt;a href="https://www.w3.org/WAI/WCAG21/Understanding/intro#understanding-the-four-principles-of-accessibility" rel="noopener noreferrer"&gt;4 principles: perceivable, operable, understandable, and robust&lt;/a&gt;. Each guideline has three levels of success criteria, &lt;a href="https://www.w3.org/WAI/WCAG21/Understanding/conformance#levels" rel="noopener noreferrer"&gt;A, AA, and AAA.&lt;/a&gt;&lt;br&gt;
We will be going over the principles for WCAG 2.1 since it is the most up to date version, it is exactly the same guidelines as WCAG 2.0 provides, but it has a few more additions. The four main principles we will be discussing are provided directly from &lt;a href="https://www.w3.org/WAI/fundamentals/accessibility-principles/" rel="noopener noreferrer"&gt;W3C’s WAI website.&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A brief overview of the 4 principles of accessibility are:&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Perceivable
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Perceivable content means that users must be able to perceive information and user interface components presented, and it can not be invisible to all of their senses.&lt;/strong&gt; &lt;br&gt;
The main ways to achieve this are to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Provide text alternatives for non-text content.
Provide captions and other alternatives for multimedia.&lt;/li&gt;
&lt;li&gt;Create content that can be presented in different ways, including by assistive technologies, without losing meaning.&lt;/li&gt;
&lt;li&gt;Make it easier for users to see and hear content.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Operable
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Operable content means creating components and navigation that are operable and a user should be able to perform the operations needed to navigate an interface.&lt;/strong&gt;&lt;br&gt;
The main ways to do this are: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make all functionality available from a keyboard.&lt;/li&gt;
&lt;li&gt;Give users enough time to read and use the content.&lt;/li&gt;
&lt;li&gt;Do not use content that causes seizures or physical reactions.&lt;/li&gt;
&lt;li&gt;Help users navigate and find content.&lt;/li&gt;
&lt;li&gt;Make it easier to use inputs other than using the keyboard.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Understandable
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Making understandable content means that users should be able to not only operate and interface but they should be able to understand the interface and information as well.&lt;/strong&gt; &lt;br&gt;
To achieve this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make text readable and understandable.&lt;/li&gt;
&lt;li&gt;Make content appear and operate in predictable ways.&lt;/li&gt;
&lt;li&gt;Help users avoid and correct mistakes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Robust
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Robust Content must be detailed enough to be used by a wide variety of user agents and assistive technologies. The main goal is to have content stay accessible as technologies and user agents evolve.&lt;/strong&gt; &lt;br&gt;
To make robust content we mainly want to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Maximize compatibility with current and future user tools.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If any of these guidelines are not met, users with disabilities may not be able to use your application. Under all of these principles, there are a total of &lt;a href="https://www.w3.org/TR/WCAG21/#toc" rel="noopener noreferrer"&gt;12 guidelines.&lt;/a&gt;&lt;br&gt;
These for principles lay the foundation for which is necessary for anyone to use your application, but it does not end here. &lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;How you can begin to implement accessibility into your applications?&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;There is a world of ways you can begin to make your applications more accessible and there are many resources to begin implementing these principles. &lt;a href="https://a11yproject.com/" rel="noopener noreferrer"&gt;The A11y Project&lt;/a&gt; is a checklist that goes over these principles and helps you checklist accessibility in your application based on WCAG. &lt;br&gt;
Another helpful tool for building accessible applications is running &lt;a href="https://developers.google.com/web/tools/lighthouse/" rel="noopener noreferrer"&gt;Google Lighthouse&lt;/a&gt; tests on Google Chrome. Lighthouse provides an accessibility score for any application whether deployed or in development mode. After running tests on Google Lighthouse there is detailed documentation on how to fixe issues your applications may have and you can begin boosting your application's accessibility score. &lt;br&gt;
I hope this was helpful in understanding what the Web Content Accessibility Guidelines are and how that is important and necessary for all applications on the web and of course, understanding what accessibility means for developers and how we should be implementing it to our applications. You can always reference &lt;a href="https://www.w3.org/TR/WCAG21/#toc" rel="noopener noreferrer"&gt;W3C’s recommendations for accessibility&lt;/a&gt; to improve your applications.&lt;/p&gt;

&lt;p&gt;Cover is from &lt;a href="https://unsplash.com/@pgreen1983" rel="noopener noreferrer"&gt;Paul Green&lt;/a&gt; on Unsplash. &lt;/p&gt;

</description>
      <category>beginners</category>
      <category>productivity</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>What The Webpack</title>
      <dc:creator>Carmen Salas</dc:creator>
      <pubDate>Thu, 02 Jul 2020 12:57:02 +0000</pubDate>
      <link>https://forem.com/cs_carms/what-is-webpack-43h6</link>
      <guid>https://forem.com/cs_carms/what-is-webpack-43h6</guid>
      <description>&lt;p&gt;Webpack can seem overwhelming and something you might have avoided learning about when building out React applications. But it is pretty simple to set up and create yourself, for your React apps. This will be a beginner’s guide into Webpack and what it’s &lt;em&gt;actually&lt;/em&gt; doing. Let’s unpack any questions you might have about Webpack… haha...&lt;/p&gt;

&lt;p&gt;We will be going over:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;What is Webpack?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How to Configure Webpack&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cache Busting in Webpack&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  What is Webpack, how does it work, and what is it doing?
&lt;/h4&gt;

&lt;p&gt;If you are familiar with Create React App, Webpack is responsible for the main functionality in Create React App, along with some other things like Babel (a JS compiler). Create React App is using Webpack to bundle your files, together, and is the reason why developing React applications using create React app is really easy. &lt;br&gt;
Webpack is a module bundler. But what does this mean? It means Webpack compiles JS files into one main file or however many files you want to bundle your code into, but typically it is one bundle file.&lt;br&gt;
Webpack comes with many features such as module bundling, file minification(the process of minimizing code by getting rid of white space, comments, unnecessary code, and minimizing/ shortening code.), SASS compilation, etc. It bundles and complies with your developing application into something that the browser can understand. &lt;br&gt;
Webpack manages dependencies and loads code that needs to be loaded first. Webpack keeps track of what files depend on what and loads them accordingly.&lt;br&gt;
The problem Webpack solves is when developing large apps, your dependencies can pile up and intersect different files which make it complex and difficult to manage. Webpack manages all these dependencies and files for you, bundles it to plain JS that the browser can understand. &lt;/p&gt;
&lt;h4&gt;
  
  
  How to Configure Webpack
&lt;/h4&gt;

&lt;p&gt;If you want to add loader and plugins to your Webpack bundle, you have to do this in a Webpack config file. &lt;br&gt;
 Here is what a webpack config file looks like.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;//Webpack.config.js file:&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;path&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;development&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./src/index.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;main.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dist&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s unpack what is happening in this file.&lt;/p&gt;

&lt;p&gt;First, we set the &lt;code&gt;mode&lt;/code&gt; to be &lt;code&gt;development&lt;/code&gt; and this tells the Webpack not to minify our code, which is extremely helpful when developing. &lt;br&gt;
We then, have to make sure everything we have in this file is exported as a module if we want to use it.&lt;br&gt;
In your &lt;code&gt;package.json&lt;/code&gt; file, created when you initialize your application with &lt;code&gt;npm init&lt;/code&gt; you can tell Webpack to run in &lt;code&gt;scripts&lt;/code&gt; like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;scripts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;start&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;webpack  --config webpack.config.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="c1"&gt;//The webpack config file can be named anything,&lt;/span&gt;
&lt;span class="c1"&gt;//In this case, it is webpack.config.js&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next the &lt;code&gt;entry&lt;/code&gt; property, takes in the src of where your entire application runs. By default, Webpack will look for an &lt;code&gt;index.js&lt;/code&gt; file in a &lt;code&gt;src&lt;/code&gt; folder but here is where you can specify the file where your application starts and what code needs to be bundled. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;output&lt;/code&gt; property is an object, where you want your code to be outputted. The &lt;code&gt;filename&lt;/code&gt; property can be named anything you’d like, typically it is &lt;code&gt;main.js&lt;/code&gt;. &lt;br&gt;
The &lt;code&gt;path&lt;/code&gt; property specifies where you want the code to go. In this case, we are resolving an absolute path to the &lt;code&gt;dist&lt;/code&gt; directory, you can call this folder anything. Essentially this is the folder that Webpack will bundle your application in, traditionally this folder is &lt;code&gt;dist&lt;/code&gt;.&lt;br&gt;
This is the basics for configuring your Webpack file and how to get Webpack to run your application. There is of course more you can add to this config file such as loaders and plugins. You can refer to the &lt;a href="https://webpack.js.org/configuration/" rel="noopener noreferrer"&gt;Webpack docs&lt;/a&gt; if you are interested in this. &lt;/p&gt;
&lt;h4&gt;
  
  
  Cache busting in Webpack
&lt;/h4&gt;

&lt;p&gt;Cache busting can be a confusing topic at first, but it can be important to the functionality of your application and something that can be easily done in a Webpack. &lt;br&gt;
When you bundle up your application with Webpack, Webpack bundles everything up in a deployable &lt;code&gt;/dist&lt;/code&gt; directory. &lt;br&gt;
Once your application is deployed to a server, and a user is visiting your application, the client (typically a browser) has to reach the server again to retrieve all of the application’s assets.&lt;br&gt;
This is why browsers cache application assets. Essentially they save files or modules form the &lt;code&gt;/dist&lt;/code&gt; directory so that the next time the user refreshes or visits the browser doesn’t have to retrieve any assets it already remembers. &lt;br&gt;
How to prevent browsers to cache bundles for CSS or files we have made changes to?&lt;br&gt;
The browser caching files can cause a problem because if we change files that have been cached, the browser might not update them and assume the file is the same just because the name of the file hasn’t changed.&lt;br&gt;
The idea behind cache busting is we want to create a new file name every time you make changes to a file and keep the file name the same if you haven’t made changes. This way when you have made changes to a file, when the client makes requests to the server to retrieve the application assets, the files you have changed will update since the browser does not recognize the filenames. &lt;br&gt;
Luckily, a Webpack comes with a built-in substitution feature in &lt;code&gt;output.filename&lt;/code&gt; in the Webpack config file called &lt;code&gt;[contenthash]&lt;/code&gt;.&lt;br&gt;
The &lt;code&gt;[contenthash]&lt;/code&gt; substitution will create a unique hash based on whether the content of an asset has changed or not, updating only when it does.&lt;br&gt;
When you add &lt;code&gt;[contenthash]&lt;/code&gt; to the output object in your config file it will look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;//the output object in module.exports from the webpack.config.js file:&lt;/span&gt;

&lt;span class="nx"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;main.[contentHash].js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dist&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;So&lt;/strong&gt;, I hope this introduction to Webpack was easy to digest and answered a few questions you might have had about Webpack. Webpack is doing a lot of the behind the scenes work to make your React applications work, all you need to do is make sure you configure it correctly for your application. Next time you're working on a React app, consider configuring Webpack yourself!&lt;/p&gt;

</description>
      <category>react</category>
      <category>beginners</category>
      <category>node</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Lazily Suspending in React</title>
      <dc:creator>Carmen Salas</dc:creator>
      <pubDate>Mon, 29 Jun 2020 13:54:17 +0000</pubDate>
      <link>https://forem.com/cs_carms/lazy-and-suspense-in-react-2gn7</link>
      <guid>https://forem.com/cs_carms/lazy-and-suspense-in-react-2gn7</guid>
      <description>&lt;p&gt;&lt;em&gt;By Carmen Salas&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I am currently learning how I can optimize the performance of my React applications. When wanting to render components in an application it can take time and slow down your application. One of the React functions I am learning about is &lt;code&gt;React.lazy&lt;/code&gt;, which allows your components to lazy-load. Let’s talk about how we use lazy in conjunction with React’s newer feature, Suspense. &lt;/p&gt;

&lt;p&gt;We’ll go into: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;What is lazy loading and why is it important?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is lazy loading in React?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is Suspense in React?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How to use React.lazy and Suspense in a React application&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What is lazy loading and why is it important?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Lazy loading stops a webpage from rendering all of its contents at once. Lazy loading allows the contents of a page to render only when a user reaches that part of the page. An application basically holds off on rendering contents if a user does not reach the section of the page with those contents. &lt;br&gt;
The benefits of this, are that it optimizes time and space for content delivery on an application. &lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;What is lazy loading in React?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;React has a function &lt;code&gt;react.lazy&lt;/code&gt;, which makes it easy to lazily load the contents of a page by code splitting. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;react.lazy&lt;/code&gt; bundles components you are importing to automatically load when rendering the entire page &lt;/p&gt;

&lt;p&gt;The way &lt;code&gt;react.lazy&lt;/code&gt; works is it takes in a function that must call a dynamic import. This means a promise is returned which resolves to a default exported module that is in your application. &lt;/p&gt;

&lt;p&gt;Here’s how you would use it in an application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Banner&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lazy&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../HomePage/Banner&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will make the &lt;code&gt;Banner&lt;/code&gt; component in my application lazily load when I use it, as opposed to how I would normally import it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Banner&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../HomePage/Banner&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now if we want to use the lazy function in our application we have to wrap the lazy component in a Suspense component &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What is Suspense in React?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;&amp;lt;Suspense&amp;gt;&lt;/code&gt; component is a new addition to React 16.6. It will essentially wait to see if what you want to load is ready to load, and while waiting, &lt;code&gt;Suspense&lt;/code&gt; will render a &lt;code&gt;fallback&lt;/code&gt;. &lt;br&gt;
&lt;code&gt;Suspense&lt;/code&gt; takes in a prop called fallback which is your loading state,&lt;br&gt;
While loading,&lt;code&gt;Suspense&lt;/code&gt; will give you the fallback this could be a component, like a loading spinner or text.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;How to use React.lazy and Suspense in a React application&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Now that we know how lazy and Suspense will work together to lazily load contents on to your application let’s see how the code looks. &lt;/p&gt;

&lt;p&gt;This is how we would wrap our lazy component in a Suspense component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Suspense&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Spinner&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-bootstrap/Spinner&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Suspense&lt;/span&gt; &lt;span class="nx"&gt;fallback&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Spinner&lt;/span&gt; &lt;span class="nx"&gt;animation&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;border&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;variant&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;info&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Banner&lt;/span&gt;&lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Suspense&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here I wrapped my lazy component &lt;code&gt;Banner&lt;/code&gt; in the &lt;code&gt;Suspense&lt;/code&gt; component and set the fallback in Suspense to be a spinner component imported from React Bootstrap. &lt;/p&gt;

&lt;p&gt;Pretty simple right?&lt;/p&gt;

&lt;p&gt;This will then lazily load the Banner component in my application. While loading a react-bootstrap spinner will render on the page while the Suspense component is waiting to see is the Banner component is ready. &lt;/p&gt;

&lt;p&gt;It will look something like this: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3nlfkeo2ya1a09x8akwe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3nlfkeo2ya1a09x8akwe.png" alt="image of loading spinner in application" width="800" height="260"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In conclusion&lt;/em&gt;&lt;/strong&gt;,&lt;/p&gt;

&lt;p&gt;These pretty new features from React are really great for optimizing the performance of your applications when it comes to loading and rendering components. This is a pretty simple way to show how to implement lazy loading in your react components but there are endless possibilities in which you can use lazy and Suspense to upgrade and benefit your applications. Try it out! &lt;/p&gt;

&lt;p&gt;Cover by Jen Theodore on Unsplash&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>tutorial</category>
      <category>productivity</category>
    </item>
    <item>
      <title>The Read on Redux (vs Context)</title>
      <dc:creator>Carmen Salas</dc:creator>
      <pubDate>Mon, 15 Jun 2020 11:44:26 +0000</pubDate>
      <link>https://forem.com/cs_carms/redux-vs-context-2b92</link>
      <guid>https://forem.com/cs_carms/redux-vs-context-2b92</guid>
      <description>&lt;p&gt;A question I ran into when learning Redux was:&lt;br&gt;
What’s the difference between the React Context API and Redux? &lt;br&gt;
So I did some research...&lt;/p&gt;

&lt;p&gt;What we will go over: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What is Redux?&lt;/li&gt;
&lt;li&gt;What is Context?&lt;/li&gt;
&lt;li&gt;How does data flow when using Context and Redux?&lt;/li&gt;
&lt;li&gt;The Pros and Cons of Redux and Context&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is Context?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The React Context API creates "global" data that can be easily be passed down in a tree of components. This is used as an alternative to “prop drilling” where you have to traverse through a component tree to pass down data with props.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;React Context consists of:&lt;/strong&gt;&lt;/p&gt;
&lt;h5&gt;
  
  
  React.createContext
&lt;/h5&gt;

&lt;p&gt;This is where you create a Context object. This is the object that wraps around your components and allows the children components to subscribe to the Context object. When a child component renders it will read the current context value from the closest matching Provider above it in the tree.&lt;/p&gt;
&lt;h5&gt;
  
  
  Context.Provider
&lt;/h5&gt;

&lt;p&gt;Every Context Object comes with a Provider React Component which wraps around components you want to be subscribed to the Context object and changes that happen to the context.  Every component wrapped in the Provider component is a consumer of the context.&lt;br&gt;&lt;br&gt;
The Provider component accepts a value prop that is passed to consuming components&lt;br&gt;
The main thing to remember is that all consumers of a Provider will re-render whenever there is a change to the Provider’s value prop. &lt;/p&gt;

&lt;p&gt;I like to think of Context as a flower pot. The Provider component is like the pot of the plant. The Provider component takes in data through the value prop similar to how the flower pot takes in water. That data is then available to the consumers of the Context much like water flows through an entire plant from the watered pot. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Redux?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Redux is a state management library used to store and manage the state of a react application in a centralized place. Redux abstracts all states from the app into one globalized state object so that any component and any part of the app can access the different properties of the global state. Redux is separate from React and there are tools react offers to help integrate Redux into React apps such as the React Toolkit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Redux consists of:&lt;/strong&gt;&lt;/p&gt;
&lt;h5&gt;
  
  
  Actions
&lt;/h5&gt;

&lt;p&gt;Actions describes what you wanna do to your states.&lt;/p&gt;
&lt;h5&gt;
  
  
  Reducers
&lt;/h5&gt;

&lt;p&gt;Reducers describe how your actions transform from state to state and keeps track of the actions you are switching from.&lt;/p&gt;
&lt;h5&gt;
  
  
  The store
&lt;/h5&gt;

&lt;p&gt;The Store is the object that brings the actions and reducers together. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How does data flow when using Context and Redux?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To best demonstrate how Context and Redux are used, I created a code sandbox where I demo both Redux and Context in a small application. In my app, each pet is either asleep or awake. Click the &lt;code&gt;Wake Up&lt;/code&gt; or &lt;code&gt;Sleep&lt;/code&gt; buttons to see how each pet image is rendered using Redux or Contex in the console.&lt;/p&gt;

&lt;p&gt;If you click the &lt;code&gt;Context&lt;/code&gt; button, the console will log what pets have been rendered using Context. &lt;/p&gt;

&lt;p&gt;If you click the &lt;code&gt;Redux&lt;/code&gt; button, the console will log what pets have been rendered using Redux. &lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/redux-vs-context-p9ty0?module=/src/context.js"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;There are a few ways you can use Redux in a React application. In the &lt;code&gt;redux.js&lt;/code&gt; file, we took advantage of some of the APIs from the Redux toolkit package. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;These are the different parts that make the data flow in the Redux demo:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;createAction()&lt;/code&gt;&lt;/strong&gt; is a helper function that accepts an object of reducer functions a slice name, and an initial state value. It will automatically generate action creators and action types that correspond to the reducers and state.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;configureStore()&lt;/code&gt;&lt;/strong&gt; is an abstraction over the standard &lt;code&gt;createStore&lt;/code&gt; in Redux, which creates the global store. In the example, our reducer is being passed in. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;connect()&lt;/code&gt;&lt;/strong&gt; this function connects a React component to a Redux store.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We then use &lt;strong&gt;&lt;code&gt;&amp;lt;Provider&amp;gt;&lt;/code&gt;&lt;/strong&gt; to make the store available to the components. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Notice how when you click the button of one pet, the other pets do not render in the Redux demo. This is because, in &lt;br&gt;
&lt;code&gt;connect()&lt;/code&gt;, when &lt;code&gt;mapState&lt;/code&gt; is called, it will check to see if the state has changed or not, only if it has it will re-render. This is one of the benefits of using Redux and helps optimize larger applications with many changing states.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Pros and Cons of Redux and Context&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Both Context and Redux are ways to manage state in a React app.&lt;/p&gt;

&lt;p&gt;The main benefit of using Context is that it is simpler to use and is a great way of passing state down to any level of a component tree without having to pass props down through traversal.&lt;/p&gt;

&lt;p&gt;The cons of using Context is that unless you separate your different states into separate Providers, the consumers of a provider will rerender if the context of a Provider changes. This can be very inefficient in a large app where the are many states you use as the context in a provider or if only a few states change that effect the renderings of other components. &lt;/p&gt;

&lt;p&gt;Redux, on the other hand, attempts to make state mutations predictable by imposing certain restrictions on how and when updates can happen and are great for applications that have multiple states that will reach different components in a component tree. Redux comes in handy when you have an app that has a more complex state that is updating frequently. The main benefit is that if states have not changed they will not re-render. &lt;/p&gt;

&lt;p&gt;Ultimately it depends on the size of your applications and what kinds of states your components will be using.  &lt;/p&gt;

</description>
      <category>react</category>
      <category>redux</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>The Scoop On Scope (In JavaScript)</title>
      <dc:creator>Carmen Salas</dc:creator>
      <pubDate>Wed, 18 Dec 2019 17:37:01 +0000</pubDate>
      <link>https://forem.com/cs_carms/the-scoop-on-scope-in-javascript-2g2j</link>
      <guid>https://forem.com/cs_carms/the-scoop-on-scope-in-javascript-2g2j</guid>
      <description>&lt;p&gt;&lt;em&gt;By Carmen Salas&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Scoping in JavaScript refers to what variables your program has access to at any given moment in time. So let’s start scooping into this scope stuff...&lt;/p&gt;

&lt;h3&gt;
  
  
  What are the different types of scopes?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Global scope&lt;/li&gt;
&lt;li&gt;Function scope &lt;/li&gt;
&lt;li&gt;Block scope &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By default, when coding in JavaScript, you start in the &lt;em&gt;window scope&lt;/em&gt; or the &lt;em&gt;root scope&lt;/em&gt;. This is the &lt;em&gt;global scope&lt;/em&gt;. This means there is only one global scope in a JS document. &lt;/p&gt;

&lt;h3&gt;
  
  
  Global Variables
&lt;/h3&gt;

&lt;p&gt;Declaring a variable outside of a function is creating a &lt;em&gt;global&lt;/em&gt; variable. Global variables have a global scope. Variables in the global scope can be accessed anywhere else in your program, in any other scope.  &lt;/p&gt;

&lt;h3&gt;
  
  
  Local Variables
&lt;/h3&gt;

&lt;p&gt;Unlike global variables, &lt;em&gt;local variables&lt;/em&gt; are only available inside an enclosed part of your program such as a function or block scope, like &lt;em&gt;if statements&lt;/em&gt; or &lt;em&gt;loops&lt;/em&gt;. A local variable has a local scope..&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;globalVar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;This is a global variable&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;globalVar&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="c1"&gt;// This will log  ‘This is a global variable’&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;localScope&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;localVar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;This is a local variable&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;localVar&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;span class="c1"&gt;// This will log ‘This is a local variable’&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;globalVar&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;span class="c1"&gt;// This will log  ‘This is a global variable’&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;localVar&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;span class="c1"&gt;// This will throw an error: ReferenceError: LocalVar is not defined&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;If you run this code, the global variable &lt;code&gt;globalVar&lt;/code&gt; can be accessed inside the function &lt;code&gt;localScope&lt;/code&gt;. However, the local variable &lt;code&gt;localVar&lt;/code&gt; can only be accessed in the scope of the function &lt;code&gt;localScope&lt;/code&gt; and not in the global scope.&lt;/p&gt;

&lt;p&gt;You can think of local scopes as a diary. Pretend you are a child keeping a diary (a local scope). You can write whatever you want inside of your diary (i.e. create as many variables as you want in a function), and name events that took place outside of your diary (accessing global variables outside of your function or calling other functions). However, no one else can look inside your diary, ESPECIALLY not your parents...cough...cough...&lt;strong&gt;GLOBAL SCOPES&lt;/strong&gt;. Similar to how a parent is not able to look inside a child’s diary, you are not able to access local variables in the global scope. &lt;/p&gt;

&lt;h3&gt;
  
  
  Function Scope
&lt;/h3&gt;

&lt;p&gt;If you declare a variable inside of a function, the variable can only be accessed within that function creating a function scope.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;myMoney&lt;/span&gt; &lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;me&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;This is my money&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;me&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;span class="c1"&gt;//This logs "This is my money"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;yourMoney&lt;/span&gt; &lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;you&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;This is your money&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
     &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;me&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;span class="c1"&gt;//This will throw an error: ReferenceError: me is not defined&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;If you run this code, the variable &lt;code&gt;me&lt;/code&gt; in the function &lt;code&gt;myMoney&lt;/code&gt; is not accessible in the function &lt;code&gt;ourMoney&lt;/code&gt;. When console logging &lt;code&gt;me&lt;/code&gt; in &lt;code&gt;yourMoney&lt;/code&gt;, an error is thrown.&lt;br&gt;
Functions do not have access to each other’s scopes.&lt;/p&gt;
&lt;h3&gt;
  
  
  Block Scope
&lt;/h3&gt;

&lt;p&gt;If you declare a variable inside curly brackets &lt;code&gt;{ }&lt;/code&gt; like in an &lt;code&gt;if&lt;/code&gt; statement or &lt;code&gt;for&lt;/code&gt; loop, you are creating a block scope. &lt;/p&gt;
&lt;h3&gt;
  
  
  Variable Keywords
&lt;/h3&gt;

&lt;p&gt;Variables declared with the keywords &lt;code&gt;let&lt;/code&gt; or &lt;code&gt;const&lt;/code&gt; have a &lt;strong&gt;block scope&lt;/strong&gt;.&lt;br&gt;
Variables declared with the keyword &lt;code&gt;var&lt;/code&gt; have a &lt;em&gt;function scope&lt;/em&gt;. Variables declared with &lt;code&gt;var&lt;/code&gt; can only be accessed within the function where they were declared (or globally, if they were declared in the global scope). &lt;code&gt;Var&lt;/code&gt; only has a &lt;em&gt;local scope&lt;/em&gt; when declared inside a function, meaning if a variable is declared within a block, it can be accessed outside of that block.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;blockScope&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;unavailable&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;   
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;onlyFunctionScope&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;available&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;blockScope&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;span class="c1"&gt;//This will throw an error: ReferenceError: BlockScope is not defined&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;onlyFunctionScope&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//This will log 'avaialable'&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;If you run this code, only the &lt;code&gt;var&lt;/code&gt; keyword variable will log its value outside of the block scope of the &lt;code&gt;if&lt;/code&gt; statement. This does not happen with the variable &lt;code&gt;blockScope&lt;/code&gt; because it was declared with the keyword &lt;code&gt;let&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;However,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;varScope&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;onlyFunctionScope&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;available&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;onlyFunctionScope&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;onlyFunctionScope&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;span class="c1"&gt;// This will throw an error: onlyFunctionScope is not defined &lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;If you run this code, the variable &lt;code&gt;onlyFunctionScope&lt;/code&gt; is not available outside of the function &lt;code&gt;varScope&lt;/code&gt; because it was declared with &lt;code&gt;var&lt;/code&gt; and this is a function scope keyword. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;In conclusion&lt;/em&gt;, creating a new function or block statement (anything with curly brackets &lt;code&gt;{}&lt;/code&gt;), you are creating a new scope. Overall, gaining an understanding of how scoping works in JavaScript, will help you track bugs and help you avoid creating collisions. Understanding variables and their scope will allow you to create more efficient programs that are properly named. You will be better at declaring variables and choosing what variables will go where. When creating the same &lt;em&gt;global variable&lt;/em&gt; twice in a large program, you can easily run into bugs, but thanks to &lt;em&gt;local scopes&lt;/em&gt;, you do not have to rely on global scopes to store data. Which can be confusing in the long run or when working on larger projects. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>fundamentals</category>
      <category>functional</category>
    </item>
  </channel>
</rss>
