<?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>DEV Community: Kemystra</title>
    <description>The latest articles on DEV Community by Kemystra (@kemystra).</description>
    <link>https://dev.to/kemystra</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%2F810220%2Fe9956513-8497-4d99-a08c-9c49e3d67f95.jpeg</url>
      <title>DEV Community: Kemystra</title>
      <link>https://dev.to/kemystra</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kemystra"/>
    <language>en</language>
    <item>
      <title>What does REST APIs mean anyway?</title>
      <dc:creator>Kemystra</dc:creator>
      <pubDate>Sun, 28 Aug 2022 13:53:31 +0000</pubDate>
      <link>https://dev.to/kemystra/what-does-rest-apis-mean-anyway-53j1</link>
      <guid>https://dev.to/kemystra/what-does-rest-apis-mean-anyway-53j1</guid>
      <description>&lt;h2&gt;
  
  
  Why I'm talking about this
&lt;/h2&gt;

&lt;p&gt;REST API (or RESTful API) is one of those technical term that is always thrown around when people talk about web dev.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Here, we can use a REST API from openweathermap...&lt;br&gt;
...make sure that your APIs are RESTful...&lt;br&gt;
Cat-as-a-Service is a RESTful API service...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It's not really a problem when you are casually learning, until you have to hit StackOverflow (which is basically everyday):&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I'm not sure if this way of doing stuff is RESTful.&lt;br&gt;
Your API is not RESTful, fix that.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In a spree of Google searches, you opened (yet) another tab and started looking up what is REST. And all you get after getting dangerously near to the limits of your poor RAM is some techobabble mumbo jumbo. Making the matter worse is that English is in fact, my second language. (I thrived writing blogs with online grammar checkers, super helpful).&lt;/p&gt;

&lt;p&gt;At least those are my experiences, and here I would like to rephrase them with extra clarity. We will go phrase by phrase, and clarify them one part at a time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's start with APIs
&lt;/h2&gt;

&lt;p&gt;API stands for &lt;strong&gt;application programming interface&lt;/strong&gt;. Let's see what we can do with this.&lt;/p&gt;

&lt;p&gt;You can also define APIs as &lt;strong&gt;interfaces for programming applications&lt;/strong&gt;. Compare that with &lt;strong&gt;user interface&lt;/strong&gt;, an interface for users.&lt;/p&gt;

&lt;p&gt;For non-English natives, &lt;strong&gt;interface&lt;/strong&gt; is the point where two systems meet.&lt;/p&gt;

&lt;p&gt;All in all, the "verbose" definition of API is &lt;strong&gt;a point where two applications meet, and developers may use this point to do certain functions&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In the case of web development, an API is often referring to a URL that returns JSON instead of a webpage. That URL is the &lt;strong&gt;endpoint&lt;/strong&gt; of the API. A refresher for you: URL means &lt;strong&gt;Uniform Resource Locator&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The URL functions as an identifier for its &lt;em&gt;resource&lt;/em&gt;. In a sense, resources are the "name" part of the name-value (or key-value) pair. Each resource would have its state, which is the "value" part.&lt;/p&gt;

&lt;p&gt;For example, let's say you are calling an API to request the latest weather info in Germany, and the API returns "raining".&lt;br&gt;
The URL of the API is the identifier of your resource (that is, latest weather info in Germany). And the state of the resource is its response (that is, raining).&lt;/p&gt;

&lt;h2&gt;
  
  
  So what's REST
&lt;/h2&gt;

&lt;p&gt;REST stands for &lt;strong&gt;representational state transfer&lt;/strong&gt;. And what the heck is that?&lt;/p&gt;

&lt;p&gt;REST is simply a software architecture, a set of rules on how the software should behave, and what to expect from them. They don't care how you implement them, as long as it follows these rules, or rather, &lt;strong&gt;constraints&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When calling an API, you give the server the exact URL and the HTTP method. The server receives this request, read from a database, do a sprinkle of processing, and return them to you in the form of JSON (although they can also return XML or HTML).&lt;/p&gt;

&lt;p&gt;So the whole exchange is, at a fundamental level, a &lt;em&gt;transfer&lt;/em&gt; of information. And the server transfer a &lt;em&gt;representation&lt;/em&gt; of the &lt;em&gt;state&lt;/em&gt; of the requested resource.&lt;/p&gt;

&lt;p&gt;What is the representation of state here? It's the format in which it is transferred, be it JSON, XML, or HTML.&lt;/p&gt;

&lt;p&gt;Now, let's talk about the constraints that an API has to follow to be considered RESTful.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to be RESTful
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Have a uniform interface
&lt;/h3&gt;

&lt;p&gt;This one has 4 parts:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The API request must include the resource identifier (a unique subdirectory, an attribute, etc.)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The response should be enough for the client to modify the resource&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The request &amp;amp; response should be complete; the request have all the info needed for the server to process, and the response have all the data requested.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The response need to also inform clients of possible ways to change the state of resources. For example, if you request for the name of the latest US president, the response should also includes methods to change that name. Obviously that's absurd, but that's the situation of most public APIs today. They usually serve data that are not meant to be changed by the user. As such, a lot of public APIs are not actually RESTful.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Only between independent servers and clients
&lt;/h3&gt;

&lt;p&gt;This info transfer is based on requests. A client only needs to request some data, and the server only response when it received the request. A server should not send a response without any request.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does not store sessions (stateless)
&lt;/h3&gt;

&lt;p&gt;In a RESTful API, a server has no idea about the previous requests of a client. Its response is not affected by other requests made by a client, as each request must have enough info for the server to work with.&lt;/p&gt;

&lt;h3&gt;
  
  
  Able to be layered
&lt;/h3&gt;

&lt;p&gt;In a perfect world, there is a direct connection from a client to a server. But in reality, system admins might implement a VPN for security, or caching servers in between. A RESTful API shouldn't give a f*ck about that.&lt;/p&gt;

&lt;h3&gt;
  
  
  Able to be cached
&lt;/h3&gt;

&lt;p&gt;The info that a server send should be cacheable. It is important that the client knows if their data is stale, so that they can request the latest one.&lt;/p&gt;

&lt;h3&gt;
  
  
  Able to send Code-on-demand (optional)
&lt;/h3&gt;

&lt;p&gt;Basically, a RESTful API can send a working code to the client for the client to execute. A common example of this is webpages (the server returns a render-able HTML page). But it's optional, why bother?&lt;/p&gt;

&lt;h2&gt;
  
  
  Closing words
&lt;/h2&gt;

&lt;p&gt;Lately, I have little time to polish my blogs, and while I like to maintain their quality, consistency is still a big part of it. I'm sorry if this particular piece is not living to your standard, based on my previous works.&lt;/p&gt;

</description>
      <category>api</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>How social media present your website?</title>
      <dc:creator>Kemystra</dc:creator>
      <pubDate>Thu, 11 Aug 2022 14:20:00 +0000</pubDate>
      <link>https://dev.to/kemystra/how-social-media-present-your-website-17in</link>
      <guid>https://dev.to/kemystra/how-social-media-present-your-website-17in</guid>
      <description>&lt;h2&gt;
  
  
  Why should you care
&lt;/h2&gt;

&lt;p&gt;Most people found a useful (but niche) website on social media. Where did you find out that there are sites that can generate CSS gradients if not on Twitter? Other than blogs and Google searches, social media is a big marketing opportunities for a lot of people, especially with the rise of code influencers.&lt;/p&gt;

&lt;p&gt;Your site might have descriptive meta tags for those Google bots to drool over you 🥴. You might maintain a blog (which people may or may not care), talking about the superiority of your site. But once one of your followers post your site on Twitter, it's a completely different game.&lt;/p&gt;

&lt;p&gt;A concise description of your site, accompanied by an intriguing thumbnail, will help you get those clicks.&lt;/p&gt;

&lt;p&gt;Sure you can write them yourself, but isn't it easier if it can be fetched from your site automatically? It also would help your site look professional, and not just botched during a weekend (do you 🧐?).&lt;/p&gt;

&lt;h2&gt;
  
  
  Customizing with Open Graph tags
&lt;/h2&gt;

&lt;p&gt;Open Graph tags are part of Meta's (formerly Facebook) Open Graph protocol. It's a snippet of HTML meta tags originally used by Facebook to improve the presentation of a website.&lt;/p&gt;

&lt;p&gt;To recognize these tags, they have &lt;code&gt;og:&lt;/code&gt; before the property name:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16vjd5jdowpjniho0jef.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16vjd5jdowpjniho0jef.png" alt="Screenshot of Twitter's page source, showing the OG tag"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open Graph tags are used by other websites too, including LinkedIn and Twitter. Even some messaging apps (WhatsApp, iMessage, etc.) support these tags to generate a snippet of your site.&lt;/p&gt;

&lt;p&gt;Meta (can we just call it Facebook?) provides 17 different tag names to use.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Yet another convention to learn..&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Well, you only need 3-4 of these tags to get started, so don't worry.&lt;/p&gt;

&lt;h3&gt;
  
  
  Specifying snippet's title
&lt;/h3&gt;

&lt;p&gt;The title should give a good first impression to your site. Here's how you can do it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;property=&lt;/span&gt;&lt;span class="s"&gt;"og:title"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"10 Best Bananas to Eat today"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the &lt;em&gt;raw&lt;/em&gt; title, DO NOT put your site's name or branding here. The title should serve as an accurate representation of what you're showing on the site&lt;/p&gt;

&lt;p&gt;Make sure that it's short to avoid cutoff. A good guide is 40 characters on mobile screen, and 60 on desktop screen.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;*cries in responsive layout*&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Yes, I feel you...&lt;/p&gt;

&lt;h3&gt;
  
  
  Specifying the juicy thumbnail
&lt;/h3&gt;

&lt;p&gt;Images are obviously the number one attraction in any social media. Simply insert them like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;property=&lt;/span&gt;&lt;span class="s"&gt;"og:image"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"yourmom.jpg"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The minimum recommended dimension is 1200x630. Larger images should have an aspect ratio of 1.91:1.&lt;/p&gt;

&lt;h3&gt;
  
  
  Telling the type of content
&lt;/h3&gt;

&lt;p&gt;It is much easier for social media's algorithms to understand what's your content about when you tell them what it is (duh 🙄).&lt;/p&gt;

&lt;p&gt;Here's how:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;property=&lt;/span&gt;&lt;span class="s"&gt;"og:type"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"article"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There's quite a lot of type that can be specified, take a look &lt;a href="https://ogp.me/#types" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Describe your site
&lt;/h3&gt;

&lt;p&gt;This one is pretty straighforward, I guess. Facebook (lol) recommends &lt;em&gt;2-4&lt;/em&gt; sentences, but that's definitely gonna be truncated. Instead, make it short and sweet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;property=&lt;/span&gt;&lt;span class="s"&gt;"og:description"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"Learn how to fight me"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Closing words
&lt;/h2&gt;

&lt;p&gt;ALL of these stuff are unnecessary for your site, but it helps when marketing them. The techniques of increasing traffic to a website organically (read: no fake accounts) are under a topic called SEO (Search Engine Optimizations). Here's a Fireship &lt;a href="https://youtu.be/-B58GgsehKQ" rel="noopener noreferrer"&gt;video&lt;/a&gt; to get you started.&lt;/p&gt;

&lt;p&gt;And as always, happy coding 🙌&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>html</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Why NodeJS in Front Ends?</title>
      <dc:creator>Kemystra</dc:creator>
      <pubDate>Tue, 02 Aug 2022 15:45:03 +0000</pubDate>
      <link>https://dev.to/kemystra/why-nodejs-in-front-ends-297h</link>
      <guid>https://dev.to/kemystra/why-nodejs-in-front-ends-297h</guid>
      <description>&lt;h2&gt;
  
  
  Why I wrote this
&lt;/h2&gt;

&lt;p&gt;Back when I started web development, I watched (and still watching) web developers' channels on Youtube (such as &lt;a href="https://www.youtube.com/c/Fireship"&gt;Fireship.io&lt;/a&gt;). One of the things that kept bugging me is the fact that they use NodeJS when working with front end frameworks or library.&lt;/p&gt;

&lt;p&gt;Like most developers, I googled the topics. After a few hours of banging my keyboards (both with hands and head 🙃), the things that I gathered are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;NodeJS is a runtime for JS (what?)&lt;/li&gt;
&lt;li&gt;You use NodeJS for both front-end and back-end&lt;/li&gt;
&lt;li&gt;Most "Getting Started" tutorials talk about using Node JS as server and back-end stuff (i.e: the complete opposite of front-end dev.)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;None of them answered my questions of &lt;em&gt;why&lt;/em&gt; do you use NodeJS in front end environment.&lt;/p&gt;

&lt;p&gt;Fast forward a few NodeJS intros and reading docs of front end frameworks, I finally grasped the why's and how's. And here, I would like to save the hassle of other web developers who are dipping their toes in the water.&lt;/p&gt;

&lt;h2&gt;
  
  
  A bit-sized intro to NodeJS
&lt;/h2&gt;

&lt;p&gt;Here's my best one-liner for this: "It's the browser's console without &lt;em&gt;GUIs&lt;/em&gt;". You give it JS code, and it will run them. NodeJS is actually based on Chrome's V8 JS engine, so it really is an upgraded component of a browser 🤯.&lt;/p&gt;

&lt;p&gt;It's only job is to &lt;strong&gt;run&lt;/strong&gt; JavaScript, while giving access to other stuff not commonly done on browser (read/write files, executing shell scripts, etc.)&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;So it's a &lt;strong&gt;back-end&lt;/strong&gt; software?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Technically yes, it sits on your computer (or servers), not on the browser.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Then why in the world would you develop front-end stuff with that?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As always, the truth is always a tad bit complicated.&lt;/p&gt;

&lt;h2&gt;
  
  
  Purpose of NodeJS on Front End dev.
&lt;/h2&gt;

&lt;p&gt;If you have been exposed to Python long enough &lt;del&gt;to acquire Slowness II effect&lt;/del&gt;, you may have heard of PIP. It's a &lt;strong&gt;package manager&lt;/strong&gt;, meaning that it helps you install libraries, uninstall them, and keep tracks of what you have installed.&lt;/p&gt;

&lt;p&gt;Similarly, NodeJS has NPM (though there are others, this one is the default).&lt;/p&gt;

&lt;p&gt;NPM have packages that you might expect: &lt;strong&gt;Express&lt;/strong&gt; for back-end, &lt;strong&gt;http&lt;/strong&gt; library to listen to requests, etc.&lt;/p&gt;

&lt;p&gt;But it also have front end frameworks as packages: React, Vue, Svelte, etc.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Why it's there when we have CDN links? Which one should I use now?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And here are the reasons:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Easier package management
&lt;/h3&gt;

&lt;p&gt;This is how you normally would import your favorite frameworks into your site:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://cdn.js/myframework/doDSF923HkHWEdss=="&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What's wrong with that, you ask? Well, if you have multiple frameworks, the order of tags inside the HTML file become critical. Some &lt;code&gt;script&lt;/code&gt; tags have to be put at a higher order, while have to be placed lower.&lt;/p&gt;

&lt;p&gt;Mess this up, and get ready for an afternoon debugging session 😵.&lt;/p&gt;

&lt;p&gt;NodeJS uses the CommonJS syntax for exporting and importing "modules" (e.g: importing your frameworks). So instead of &lt;code&gt;script&lt;/code&gt; tags in HTML, you use this in your JS file:&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;MyFramework&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&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;myframework&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;I do admit, it's kinda an edge case, but the next one would surely benefit &lt;em&gt;everyone&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. JS for programming development tools
&lt;/h3&gt;

&lt;p&gt;A neat aspect of NodeJS is that it allows building tools that can seamlessly interact with your front end code, because it natively uses JS. Development tools can include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Module bundlers&lt;/strong&gt;, which combine all your JS code and its dependencies into one massive file. Examples include &lt;a href="https://webpack.js.org/"&gt;webpack&lt;/a&gt; and &lt;a href="https://browserify.org/"&gt;browserify&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tree shakers&lt;/strong&gt;, which "shakes" unused or dead codes from your JS files. One of them is &lt;a href="https://github.com/browserify/common-shakeify"&gt;common-shakeify&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and others...&lt;/p&gt;

&lt;p&gt;Sure, you can use &lt;em&gt;any&lt;/em&gt; language under the sun to program these, but parsing JS code is better done with JS itself.&lt;/p&gt;

&lt;p&gt;And to use JS, you need a way to run JS without browser, hence NodeJS.&lt;/p&gt;

&lt;p&gt;Also, front-end developers don't have to force another programming language's syntax inside their head just to make a dev tool 😵‍💫. They understand what they want, so why don't we give them a little push?&lt;/p&gt;

&lt;h2&gt;
  
  
  Closing words
&lt;/h2&gt;

&lt;p&gt;So, I guess that's all I have to say about this. TLDR; people use NodeJS because it's easier to manage libraries, while having access to lots of dev tools.&lt;/p&gt;

&lt;p&gt;There are certainly other alternatives to NodeJS, like &lt;a href="https://bun.sh/"&gt;bun&lt;/a&gt; and &lt;a href="https://deno.land/"&gt;deno&lt;/a&gt;. These are the same stuff (with additional... stuff), their function is to run JS outside of your browser.&lt;/p&gt;

&lt;p&gt;They are the same stuff at the end of the day, and you can choose whatever you like. Though NodeJS is &lt;em&gt;way&lt;/em&gt; more popular.&lt;/p&gt;

&lt;p&gt;Happy coding! 🙌&lt;/p&gt;

</description>
      <category>node</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Day 25-33: JS Calculator</title>
      <dc:creator>Kemystra</dc:creator>
      <pubDate>Thu, 26 May 2022 14:14:04 +0000</pubDate>
      <link>https://dev.to/kemystra/day-25-33-js-calculator-5fp8</link>
      <guid>https://dev.to/kemystra/day-25-33-js-calculator-5fp8</guid>
      <description>&lt;p&gt;&lt;em&gt;Procrastinated too much after the JS Calculator project, I should be more consistent.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The project
&lt;/h2&gt;

&lt;p&gt;The aim is to build a calculator with Javascript, with the help of frameworks and libraries. I'd never actually build a calculator in any language before, so I'm not too familiar with its algorithm (and it certainly shows if you follow my &lt;a href="https://twitter.com/Kemystra"&gt;Twitter&lt;/a&gt; lol).&lt;/p&gt;

&lt;p&gt;This is the first project where I got to use Redux to manage states. There's too much boilerplate code to use it in small projects, but now I'm facing into this, might as well use it.&lt;/p&gt;

&lt;p&gt;In total I used React, Redux, SASS, and FontAwesome. For math formulas evaluation, I use &lt;a href="https://mathjs.org/"&gt;math.js&lt;/a&gt; library.&lt;/p&gt;

&lt;h2&gt;
  
  
  Result
&lt;/h2&gt;

&lt;p&gt;Here it is:&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/Kemystra/embed/KKQzQaV?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned from it
&lt;/h2&gt;

&lt;h3&gt;
  
  
  I'm still not good in programming
&lt;/h3&gt;

&lt;p&gt;This project took me a week, and it revealed my weakness in problem solving in programming. It can be dark at times, but I have to understand that I still have a long way to go before being good enough in programming.&lt;/p&gt;

&lt;p&gt;There's quite a lot that I didn't know. Algorithms and data structures, design patterns, programming paradigms, etc. These are tools that may help me in this project and other projects in the future.&lt;/p&gt;

&lt;p&gt;In a nutshell, more learning is absolutely necessary to thrive in this field where competitions are fierce and people come and go.&lt;/p&gt;

&lt;h3&gt;
  
  
  Never underestimate a project's complexity
&lt;/h3&gt;

&lt;p&gt;Upon seeing a problem, I pulled the keyboard, opened VSCodium,  and started typing away. This is honestly a bad practice of mine. Getting stuck midway is a punch to the face that I deserve for my ignorance.&lt;/p&gt;

&lt;p&gt;A good problem solver would approach a problem with caution and an eagle eye, so that they can spot weird edge cases or possible bugs ahead of time. And no, that's not me. I simply head-dive into the problem, only to be completely &lt;em&gt;bugged&lt;/em&gt; later.&lt;/p&gt;

&lt;p&gt;As such, I learned that a proper planning prior to actually writing code is necessary. You don't want to get bugged, do you?&lt;/p&gt;

&lt;h3&gt;
  
  
  React's logic separation is actually good
&lt;/h3&gt;

&lt;p&gt;Yeah I understand now why React do this. The idea of isolating UI code and the logic really does come easy to me. There's not much to say about this LOL.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pay attention on package version requirement
&lt;/h3&gt;

&lt;p&gt;Although FreeCodeCamp doesn't enforce this, their unit tests only supports certain keywords (e.g: &lt;code&gt;ReactDOM.render&lt;/code&gt;) that are not up-to-date to React 18. This one tied my development for a week, and a simple package version warning would have made this a lot easier.&lt;/p&gt;

&lt;h2&gt;
  
  
  Afterwords
&lt;/h2&gt;

&lt;p&gt;Calculator JS was, and still, the biggest project that I have finished. It's hard but it's worth it. Now that I realize my weakness, I can work to improve myself to be a better developer.&lt;/p&gt;

&lt;p&gt;Follow me on &lt;a href="https://github.com/Kemystra"&gt;Github&lt;/a&gt;!&lt;br&gt;
Also on &lt;a href="https://twitter.com/Kemystra"&gt;Twitter&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>100daysofcode</category>
      <category>javascript</category>
      <category>react</category>
      <category>redux</category>
    </item>
    <item>
      <title>Day 20-24: Drum Machine</title>
      <dc:creator>Kemystra</dc:creator>
      <pubDate>Sun, 01 May 2022 13:14:15 +0000</pubDate>
      <link>https://dev.to/kemystra/day-20-24-drum-machine-4d27</link>
      <guid>https://dev.to/kemystra/day-20-24-drum-machine-4d27</guid>
      <description>&lt;h2&gt;
  
  
  The project
&lt;/h2&gt;

&lt;p&gt;As the name suggest, we're gonna make a site with drum pads that play sound when triggered 🥁. The site was made with React and SASS. I figured I'll take 3 days to complete this, but circumstances pushed this to 4 days. Life &lt;em&gt;always&lt;/em&gt; get in the way, so I should be more prepared about it 💪&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;How to dynamically render components in React&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We can use array and its methods, such as &lt;code&gt;Array.map()&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;soundArr&lt;/span&gt; &lt;span class="o"&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;blip&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;clan&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;clap&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;cymbal&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;kclick&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;piano1&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;piano2&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;snaps&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;whoop&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;keyArr&lt;/span&gt; &lt;span class="o"&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;Q&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;W&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;E&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;A&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;S&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;D&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;Z&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;X&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;C&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"drum-machine"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"drum-title"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Drum Machine&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Display&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;soundArr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;soundClip&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;DrumPad&lt;/span&gt; &lt;span class="na"&gt;audioName&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;soundClip&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;keyArr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;cap&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;keyArr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;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;ul&gt;
&lt;li&gt;
&lt;code&gt;onkeydown&lt;/code&gt; event on the document&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To detect key presses on the HTML document, we can use the &lt;code&gt;onkeydown&lt;/code&gt; event:&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="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onkeydown&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;pressedSound&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toUpperCase&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pressedSound&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;pressedSound&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;play&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;display&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pressedSound&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parentElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&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;Note that there used to be &lt;code&gt;onkeypress&lt;/code&gt; event, but it is now deprecated.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add gradient overlay over background image&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We can use &lt;code&gt;background-image&lt;/code&gt; CSS property for this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;background-image&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;linear-gradient&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;180&lt;/span&gt;&lt;span class="nt"&gt;deg&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;rgba&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;255&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;233&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; &lt;span class="nt"&gt;rgba&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;1&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="err"&gt;100&lt;/span&gt;&lt;span class="o"&gt;%),&lt;/span&gt; 
    &lt;span class="nt"&gt;url&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;'https://t4.ftcdn.net/jpg/03/58/36/11/360_F_358361101_z9baaIEmkyst0OQ8mov82r9hen7glZGb.jpg'&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Afterwords
&lt;/h2&gt;

&lt;p&gt;It's nearing the end of Ramadan, which means preparation for Eid is incoming. It will be a very busy week. Hope I can still continue doing this throughout Eid celebration.&lt;/p&gt;

&lt;p&gt;Anyway, happy Eid for Muslims around the world! ✨&lt;/p&gt;

&lt;p&gt;Follow me on &lt;a href="https://github.com/Kemystra"&gt;Github&lt;/a&gt;!&lt;br&gt;
Also on &lt;a href="https://twitter.com/kemystra"&gt;Twitter&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>100daysofcode</category>
      <category>beginners</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>Day 17-19: Markdown Previewer</title>
      <dc:creator>Kemystra</dc:creator>
      <pubDate>Mon, 25 Apr 2022 13:31:08 +0000</pubDate>
      <link>https://dev.to/kemystra/day-17-19-markdown-previewer-5c2j</link>
      <guid>https://dev.to/kemystra/day-17-19-markdown-previewer-5c2j</guid>
      <description>&lt;p&gt;&lt;em&gt;This post is about the Markdown Previewer project on FreeCodeCamp. This is how I started the project.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The essentials
&lt;/h2&gt;

&lt;p&gt;I decided to not use Redux yet, because I only need to maintain one state inside the whole app. Redux would be such an overkill.&lt;/p&gt;

&lt;p&gt;I got to use Prism.js and marked.js library for this project. Although I had to drop Prism.js cause it's not working and it's not necessary anyway unless if I need to implement syntax highlighting in a site.&lt;/p&gt;

&lt;p&gt;This is a React site, with almost no static element. It is styled using SASS as a preprocesser for CSS.&lt;/p&gt;

&lt;h2&gt;
  
  
  marked.js
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;marked.js&lt;/code&gt; is a very simple library to use. You can include the CDN link to get started:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://cdnjs.cloudflare.com/ajax/libs/marked/4.0.2/marked.min.js"&lt;/span&gt; &lt;span class="na"&gt;integrity=&lt;/span&gt;&lt;span class="s"&gt;"sha512-hzyXu3u+VDu/7vpPjRKFp9w33Idx7pWWNazPm+aCMRu26yZXFCby1gn1JxevVv3LDwnSbyKrvLo3JNdi4Qx1ww=="&lt;/span&gt; &lt;span class="na"&gt;crossorigin=&lt;/span&gt;&lt;span class="s"&gt;"anonymous"&lt;/span&gt; &lt;span class="na"&gt;referrerpolicy=&lt;/span&gt;&lt;span class="s"&gt;"no-referrer"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To parse pure Markdown, use the &lt;code&gt;parse&lt;/code&gt; method:&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;textBox&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;textBox&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;marked&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;*This is italic*&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;&lt;code&gt;marked.js&lt;/code&gt; also offers a ton of options, and I'm going to talk about one here.&lt;/p&gt;

&lt;p&gt;To treat line breaks in text as an actual line break, set the necessary options to &lt;code&gt;true&lt;/code&gt; with &lt;code&gt;marked.setOptions()&lt;/code&gt;:&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="nx"&gt;marked&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setOptions&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;breaks&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="na"&gt;gfm&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also pass them as the second argument when parsing Markdown text:&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;markdownText&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 heading&lt;/span&gt;&lt;span class="dl"&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;mainDiv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&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-part&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;mainDiv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;marked&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;markdownText&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;breaks&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="na"&gt;gfm&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A big warning when using this library: you MUST implement a HTML filter before rendering them into the DOM. &lt;code&gt;marked.js&lt;/code&gt; don't have a supported built-in, so it is recommended to use DOMPurify or other HTML filter.&lt;/p&gt;

&lt;p&gt;You don't want an &lt;a href="https://owasp.org/www-community/attacks/xss/"&gt;XSS&lt;/a&gt; on your site, do you?&lt;/p&gt;

&lt;h2&gt;
  
  
  Afterwords
&lt;/h2&gt;

&lt;p&gt;This project is not really that challenging, apart from visual design (and I'm bad at designs). The next challenge though would be a jump in complexity, so I need to work harder.&lt;/p&gt;

&lt;p&gt;Anyway, have fun everyone!&lt;/p&gt;

&lt;p&gt;Fullo me on &lt;a href="http://github.com/Kemystra"&gt;Github&lt;/a&gt;!&lt;br&gt;
Also on &lt;a href="https://twitter.com/kemystra"&gt;Twitter&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>100daysofcode</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>react</category>
    </item>
    <item>
      <title>Day 16: Final SASS touch-up</title>
      <dc:creator>Kemystra</dc:creator>
      <pubDate>Thu, 21 Apr 2022 14:00:01 +0000</pubDate>
      <link>https://dev.to/kemystra/day-16-final-sass-touch-up-4655</link>
      <guid>https://dev.to/kemystra/day-16-final-sass-touch-up-4655</guid>
      <description>&lt;p&gt;&lt;em&gt;This post is a continuation of the previous post. For context, I'm making a Random Quote Machine for FreeCodeCamp projects. This is how I completed it.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding random colors 🌈
&lt;/h2&gt;

&lt;p&gt;Before this, we have completed the fading function. Now, we want to change its color each time the new quote is shown. This part is kinda trivial, this would be left as an exercise to the reader.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo5os0wvarctb18y0ip1n.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo5os0wvarctb18y0ip1n.gif" alt="Random colors"&gt;&lt;/a&gt;&lt;br&gt;
I also applied the colors to &lt;code&gt;background-color&lt;/code&gt; property of buttons and &lt;code&gt;body&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;Now, it is time to do a few touch ups!&lt;/p&gt;
&lt;h2&gt;
  
  
  Added Twitter Intent properly
&lt;/h2&gt;

&lt;p&gt;If you have seen Tweet buttons on some website, they may use Twitter Web Intent.&lt;/p&gt;

&lt;p&gt;It's a special Twitter URL that allow users to tweet some pre-defined content. The URL is placed as the &lt;code&gt;href&lt;/code&gt; attribute in a button.&lt;/p&gt;

&lt;p&gt;You can read more &lt;a href="https://developer.twitter.com/en/docs/twitter-for-websites/tweet-button/guides/web-intent" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;After placing them inside the tweet button, it's time for the final touch ups!&lt;/p&gt;
&lt;h2&gt;
  
  
  Finalizing the site
&lt;/h2&gt;

&lt;p&gt;First, made the site neat with layout adjustments.&lt;/p&gt;

&lt;p&gt;Then, added rounded corners to &lt;em&gt;all&lt;/em&gt; buttons and the quote box.&lt;/p&gt;

&lt;p&gt;I also took some fonts from &lt;a href="https://fonts.google.com" rel="noopener noreferrer"&gt;Google Fonts&lt;/a&gt; (specifically, Akshar and Open Sans font).&lt;/p&gt;

&lt;p&gt;And... we're done! How cool is that?&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fau5wai2g2smjgx4l5f4m.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fau5wai2g2smjgx4l5f4m.gif" alt="Final Result"&gt;&lt;/a&gt;'&lt;br&gt;
Now, to publish them onto &lt;a href="https://codepen.io" rel="noopener noreferrer"&gt;CodePen&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Publishing!
&lt;/h2&gt;

&lt;p&gt;CodePen only allows HTML codes that you normally put inside the &lt;code&gt;body&lt;/code&gt; tag, so we need to set inline styles to them thru JavaScript:&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;var&lt;/span&gt; &lt;span class="nx"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;same-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;documentElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;--trans-time&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;0.5s&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;Since we are not writing pure CSS or JavaScript, we need to set the preprocessors for each: Babel for JS, and SASS for CSS.&lt;/p&gt;

&lt;p&gt;We also need to put our Google Fonts link into the &lt;code&gt;head&lt;/code&gt; tag. Luckily, CodePen already have a special setting for that.&lt;/p&gt;

&lt;p&gt;The most important thing here is importing React, ReactDOM and FontAwesome library into the site. This can be done by searching the necessary package in the setting.&lt;/p&gt;

&lt;p&gt;And &lt;em&gt;now&lt;/em&gt; we're done.&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/Kemystra/embed/JjMzLGP?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Afterwords
&lt;/h2&gt;

&lt;p&gt;Yay I finished it! I'm now one step closer towards becoming a front-end developer. For those who are struggling with bugs or any random stuff, keep going! Finishing a project will make you forget about that random bug at 3am, or that dependency hell you encounter, or heck anything. It felt blissful and reassuring.&lt;/p&gt;

&lt;p&gt;Hope tomorrow would be better for you!&lt;/p&gt;

&lt;p&gt;Fullo me on &lt;a href="https://github.com/Kemystra" rel="noopener noreferrer"&gt;Github&lt;/a&gt;!&lt;br&gt;
Also on &lt;a href="https://twitter.com/kemystra" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>100daysofcode</category>
      <category>beginners</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>Day 15: Completing the site basics</title>
      <dc:creator>Kemystra</dc:creator>
      <pubDate>Wed, 20 Apr 2022 14:48:40 +0000</pubDate>
      <link>https://dev.to/kemystra/day-15-completing-the-site-basics-4jam</link>
      <guid>https://dev.to/kemystra/day-15-completing-the-site-basics-4jam</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a continuation of the previous post. Here is my journey completing the Random Quote Machine.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Passing the test 🗒
&lt;/h2&gt;

&lt;p&gt;FreeCodeCamp projects usually include a JS script that can be used to test our website.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This will render a special UI for testing on top of the site itself.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2Aad9iwH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2xt5tiq83b58rldg4lb6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2Aad9iwH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2xt5tiq83b58rldg4lb6.png" alt="Special UI" width="880" height="495"&gt;&lt;/a&gt;&lt;br&gt;
The first thing that I like to do is to complete all tests that looks for HTML elements with certain tags. I started &lt;code&gt;Five Server&lt;/code&gt; extension on VSCode, and started working.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--drdO-lDP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/az53vbt5p7nbl3p0p6u9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--drdO-lDP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/az53vbt5p7nbl3p0p6u9.png" alt="Minimal HTML" width="880" height="502"&gt;&lt;/a&gt;&lt;br&gt;
This gives me an idea what is the final structure of the website.&lt;/p&gt;

&lt;p&gt;After that, I included the necessary libraries: React, React DOM, and jQuery. Then I started &lt;code&gt;dart-sass&lt;/code&gt; and &lt;code&gt;babel&lt;/code&gt; with watch option.&lt;/p&gt;

&lt;p&gt;It's time for React code!&lt;/p&gt;
&lt;h2&gt;
  
  
  The bare minimum
&lt;/h2&gt;

&lt;p&gt;The next thing that I do was writing a &lt;code&gt;div&lt;/code&gt; with &lt;code&gt;id="wrapper"&lt;/code&gt;. This will be the root of our React stuff. After an hour I have this:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HfclOFxE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3x2mldljcd1ejlfo6665.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HfclOFxE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3x2mldljcd1ejlfo6665.png" alt="Main parent" width="880" height="502"&gt;&lt;/a&gt;&lt;br&gt;
"What?! You took an hour doing this?". Sadly, yes. I stumbled upon an error that complains about the usage of &lt;code&gt;ReactDOM&lt;/code&gt; instead of 'ReactDOM/client'. It's a black hole of energy and time 😵‍💫.&lt;/p&gt;

&lt;p&gt;It turns out that React is planning to separate its server-side rendering script with the client-side. This felt weird cause there is no CDN links for client-side one. Only a general &lt;code&gt;ReactDOM&lt;/code&gt; CDN link. I don't know how to deal with this yet, but the code still works anyway 🧐.&lt;/p&gt;

&lt;p&gt;I then proceeded to wrote the rest of components, and put them inside the parent component.&lt;/p&gt;

&lt;p&gt;The FreeCodeCamp's test confirmed that I have a correct HTML structure. It's time for the logic!&lt;/p&gt;
&lt;h2&gt;
  
  
  Playing with APIs
&lt;/h2&gt;

&lt;p&gt;As the project's name suggests, I need to show a random quote each time a user presses a button.&lt;/p&gt;

&lt;p&gt;Because I'm not too wise to make hundreds of reliable quotes, I had to find APIs that serve them. A few Google searches later, I found what I need.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/lukePeavey"&gt;
        lukePeavey
      &lt;/a&gt; / &lt;a href="https://github.com/lukePeavey/quotable"&gt;
        quotable
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Random Quotes API
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Quotable&lt;/h1&gt;
&lt;p&gt;Quotable is a free, open source quotations API. It was originally built as part of a &lt;a href="https://www.freecodecamp.org/" rel="nofollow"&gt;FreeCodeCamp&lt;/a&gt; project. If you are interested in contributing, please check out the &lt;a href="https://github.com/lukePeavey/quotableCONTRIBUTING.md"&gt;Contributors Guide&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Servers&lt;/strong&gt;&lt;/p&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;URL&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Production&lt;/td&gt;
&lt;td&gt;api.quotable.io&lt;/td&gt;
&lt;td&gt;The public API server&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Staging&lt;/td&gt;
&lt;td&gt;staging.quotable.io&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;The staging server is for testing purposes only.&lt;/strong&gt; The master branch automatically deploys to the staging server after every commit. Once changes have been tested they will be pushed to the production server.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
API Reference &lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/lukePeavey/quotable#get-random-quote"&gt;Get random quote&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/lukePeavey/quotable#list-quotes"&gt;List Quotes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/lukePeavey/quotable#get-quote-by-id"&gt;Get Quote By ID&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/lukePeavey/quotable#list-authors"&gt;List Authors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/lukePeavey/quotable#search-quotes-beta"&gt;Search Quotes (beta)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/lukePeavey/quotable#search-authors-beta"&gt;Search Authors (beta)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/lukePeavey/quotable#get-author-by-slug"&gt;Get Author By Slug&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/lukePeavey/quotable#list-tags"&gt;List Tags&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
Examples &lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://codepen.io/lukePeavey/pen/RwNVeQG" rel="nofollow"&gt;Basic Quote Machine (CodePen)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://codesandbox.io/s/quotable-demo-react-e7zm1?fontsize=14&amp;amp;hidenavigation=1&amp;amp;module=%2Fsrc%2FApp.js&amp;amp;theme=dark" rel="nofollow"&gt;React Quote Machine (CodeSandbox)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/siddsarkar/SociQuote"&gt;React Native App (Github)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://codesandbox.io/s/quotable-author-list-2-14le9" rel="nofollow"&gt;Paginated Author List (codeSandbox)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://codesandbox.io/s/quotable-get-quotes-with-author-details-iyxw8" rel="nofollow"&gt;Paginated Quote List (codeSandbox)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
Get random quote&lt;/h2&gt;
&lt;div class="highlight highlight-source-httpspec position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-k"&gt;GET&lt;/span&gt;&lt;span class="pl-c1"&gt; /random&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Returns a single random quote from the database&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Query parameters&lt;/strong&gt;&lt;/p&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;param&lt;/th&gt;
&lt;th&gt;type&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;maxLength&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Int&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The maximum Length in characters ( can&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;…&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/lukePeavey/quotable"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
The code for fetching the API is very simple:&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--V6MAG91X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9erd4rr4xv5w3v1donjz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--V6MAG91X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9erd4rr4xv5w3v1donjz.png" alt="Fetch API" width="504" height="155"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let's work on the UI!&lt;/p&gt;

&lt;h2&gt;
  
  
  Fancy effects 💫
&lt;/h2&gt;

&lt;p&gt;FreeCodeCamp gave an example for each project. This is the example for this one:&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/freeCodeCamp/embed/qRZeGZ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;br&gt;
I want to try and replicate what has been done here. So after two hours, I finally got a simple result!&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fYdbwV-e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wxovqc3jffceubii7m3f.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fYdbwV-e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wxovqc3jffceubii7m3f.gif" alt="Color change result" width="858" height="494"&gt;&lt;/a&gt;&lt;br&gt;
Notice that I didn't randomize the colors yet.&lt;br&gt;
Here's the code if you're curious:&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="nx"&gt;handleNewQuote&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;this_func&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;documentElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;--color&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;white&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;getApi&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://api.quotable.io/random?tags=famous-quotes&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="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
                &lt;span class="na"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;author&lt;/span&gt;
            &lt;span class="p"&gt;}));&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;updateQuote&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;responseData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;getApi&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="nx"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&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="nx"&gt;this_func&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&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="na"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;responseData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;responseData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;author&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;}));&lt;/span&gt;

            &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;documentElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;--color&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;red&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="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;updateQuote&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;This function is called each time the button is pressed. It also need a CSS variable &lt;code&gt;--color&lt;/code&gt;, used as the color for text. Place the variable in the &lt;code&gt;&amp;lt;HTML&amp;gt;&lt;/code&gt; tag.&lt;/p&gt;

&lt;h2&gt;
  
  
  Afterwords
&lt;/h2&gt;

&lt;p&gt;Personally, this is a big jump in React stuff. Notice that I didn't use Redux. This is because the state is simple enough that I don't want to be burdened with more unnecessary library. I felt that I like my website light, rather than bloated with features.&lt;/p&gt;

&lt;p&gt;Anyway, hope everyone else is doing good with their challenge 😁&lt;/p&gt;

&lt;p&gt;Follow me on &lt;a href="https://github.com/Kemystra"&gt;Github&lt;/a&gt;!&lt;br&gt;
Also on &lt;a href="https://twitter.com/kemystra"&gt;Twitter&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>100daysofcode</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>react</category>
    </item>
    <item>
      <title>Day 14: Random Quote Machine</title>
      <dc:creator>Kemystra</dc:creator>
      <pubDate>Tue, 19 Apr 2022 14:00:16 +0000</pubDate>
      <link>https://dev.to/kemystra/day-14-random-quote-machine-4lk1</link>
      <guid>https://dev.to/kemystra/day-14-random-quote-machine-4lk1</guid>
      <description>&lt;h2&gt;
  
  
  Setting up files
&lt;/h2&gt;

&lt;p&gt;I though I can use &lt;code&gt;npm&lt;/code&gt; and Node.js for this, so I installed  it yesterday.&lt;/p&gt;

&lt;p&gt;The project is part of the FreeCodeCamp's course, and the first one is:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ePCXnUCf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8pa1if9joyzx4v4ohquk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ePCXnUCf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8pa1if9joyzx4v4ohquk.png" alt="Random Quote Machine" width="816" height="189"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then I started off with making the three essential files for web dev:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FYRiq0oz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ugesvxgy94u4dgtxf8gu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FYRiq0oz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ugesvxgy94u4dgtxf8gu.png" alt="The three files" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And then I deleted them after realizing that I need to run &lt;code&gt;npm init&lt;/code&gt; first:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KoIj5l5c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1hwyeeqx0tiz87ythjj4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KoIj5l5c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1hwyeeqx0tiz87ythjj4.png" alt="npm init" width="723" height="625"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;And&lt;/em&gt; then I reverted back because I want to learn the basics first: I don't want important things to be hidden. Node.js and &lt;code&gt;npm&lt;/code&gt; offers good shortcut for working, but this is not going to teach me anything 🫠.&lt;/p&gt;

&lt;p&gt;So, I'm back to square one. To get a refresher on React, I made a simple counter with a button. (I used the recommended beginner config for React &lt;a href="https://reactjs.org/docs/add-react-to-a-website.html"&gt;here&lt;/a&gt;.)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QJazlF-X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/53re6l9lzbdjlcajdxvt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QJazlF-X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/53re6l9lzbdjlcajdxvt.png" alt="Simple counter" width="126" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And it worked! Yay 🥳&lt;/p&gt;

&lt;p&gt;Next step is to install preprocessors for SASS and JSX, instead of depending on external ones. I opted for &lt;code&gt;dart-sass&lt;/code&gt; and &lt;code&gt;babel-cli&lt;/code&gt;, both installed with &lt;code&gt;pacman&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;pacman &lt;span class="nt"&gt;-S&lt;/span&gt; dart-sass babel-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both of this have watch option, where it automatically compiles when the source files change. Isn't that neat?&lt;/p&gt;

&lt;p&gt;Well, the &lt;code&gt;dart-sass&lt;/code&gt; package seems to work well. But &lt;code&gt;babel-cli&lt;/code&gt; throws an error?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9u0M6Oor--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r4e5wzelspslf0tcj671.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9u0M6Oor--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r4e5wzelspslf0tcj671.png" alt="Babel Error" width="880" height="674"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A dive into StackOverflow says that I need to install &lt;code&gt;babel-preset-react&lt;/code&gt;, which means a &lt;em&gt;reinstall&lt;/em&gt; of &lt;code&gt;npm&lt;/code&gt; 🤦‍♂️.&lt;/p&gt;

&lt;p&gt;(Another thing that really bugs me is the vulnerabilities that &lt;code&gt;npm&lt;/code&gt; shows. I don't know if I should ignore this, but I'm scared.)&lt;/p&gt;

&lt;p&gt;After half an hour wrestling with dependencies and plugins 💪, I have a working &lt;code&gt;babel&lt;/code&gt; preprocessor, with the watch option.&lt;/p&gt;

&lt;p&gt;And that's already stressful enough.&lt;/p&gt;

&lt;h2&gt;
  
  
  Afterwords
&lt;/h2&gt;

&lt;p&gt;A big lesson for me today is that web development change so fast that I need to follow the official documentation to avoid deprecated solutions. &lt;/p&gt;

&lt;p&gt;Also, &lt;code&gt;npm&lt;/code&gt; packages are &lt;strong&gt;HUGE&lt;/strong&gt;. I seriously don't understand why, and for now I'll try to use other alternatives (native binary, etc.) whenever possible.&lt;/p&gt;

&lt;p&gt;I think that's all from me today. See ya!&lt;/p&gt;

&lt;p&gt;Follow me on &lt;a href="https://github.com/Kemystra"&gt;Github&lt;/a&gt;!&lt;br&gt;
Also on &lt;a href="https://twitter.com/kemystra"&gt;Twitter&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>100daysofcode</category>
      <category>beginners</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>Day 13: Preparing React Practice</title>
      <dc:creator>Kemystra</dc:creator>
      <pubDate>Mon, 18 Apr 2022 14:18:43 +0000</pubDate>
      <link>https://dev.to/kemystra/day-13-preparing-react-practice-219f</link>
      <guid>https://dev.to/kemystra/day-13-preparing-react-practice-219f</guid>
      <description>&lt;p&gt;&lt;em&gt;Looking back, this part could hurt the SEO of this blogpost. So, Google crawlers, please pick me&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Allow components to pass actions
&lt;/h2&gt;

&lt;p&gt;In the previous post, we have given React components access to states in Redux Store. Now, we are giving them ability to edit them:&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;mapDispatchToProps&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;dispatch&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;stateOne&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;actionData&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;actionCreator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;actionData&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;Note that &lt;code&gt;dispatch&lt;/code&gt; function here is mandatory. Also, &lt;code&gt;actionData&lt;/code&gt; is optional; if your action don't need one, be free to omit them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bridging the Redux-React gap
&lt;/h2&gt;

&lt;p&gt;We have declared functions to map actions and states to components props. Now, time to pick the 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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;wrappedComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ReactRedux&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;mapStatesToProps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;mapDispatchToProps&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="nx"&gt;theComponent&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Notice the ES6-style immediate call of the function?)&lt;/p&gt;

&lt;p&gt;We have essentially made a new component that contains the old component, along with the necessary part for interaction with Redux store.&lt;/p&gt;

&lt;p&gt;Also, both parameters are completely optional; you can have a component that doesn't need the state values, or the one that doesn't need to update the states, or both if you are a phsycopath. &lt;/p&gt;

&lt;p&gt;Note that states and functions that dispatch its actions are now accessible in &lt;code&gt;this.props&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Preparing environment, a.k.a the juicy part 😋
&lt;/h2&gt;

&lt;p&gt;So this is my first time actually using &lt;code&gt;npm&lt;/code&gt;. After a few Google searches, I got an idea what it is.&lt;/p&gt;

&lt;p&gt;From what I can gather, &lt;code&gt;npm&lt;/code&gt; is a package manager for JavaScript (much like &lt;code&gt;pacman&lt;/code&gt;, &lt;code&gt;apt&lt;/code&gt;, and whatnot). Where do we use the package? Inside Node.js! (Node.js is an interpreter for JavaScript, much like Python exec for... Python). &lt;/p&gt;

&lt;p&gt;Node.js has a lot things going, but we're gonna have to install them first.&lt;/p&gt;

&lt;p&gt;As a GNU/Linux user 🤵🏼 (more specifically EndeavourOS), I only need to use &lt;code&gt;pacman&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;pacman &lt;span class="nt"&gt;-S&lt;/span&gt; nodejs-lts-gallium npm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Node.js Gallium is the now-active LTS version of Node.js)&lt;br&gt;
Typed in my password and a few moments later, they are installed!&lt;/p&gt;

&lt;p&gt;As per FreeCodeCamp recommendation, I will use &lt;code&gt;create-react-app&lt;/code&gt; package. However, I don't want to install them globally. I would wait for tomorrow when I start getting my hands dirty.&lt;/p&gt;

&lt;h2&gt;
  
  
  Afterwords
&lt;/h2&gt;

&lt;p&gt;Yay, we finished the theory 🎉! Though I would need to face bugs now LOL. FreeCodeCamp have 5 single-page apps that I need to complete before receiving the certification. &lt;/p&gt;

&lt;p&gt;I'm still thinking what to do after finishing them, but for now, there will be bugs to smash 🪲👊. See you guys tomorrow!&lt;/p&gt;

&lt;p&gt;Fullo me on &lt;a href="https://github.com/Kemystra"&gt;Github&lt;/a&gt;!&lt;br&gt;
Also on &lt;a href="https://twitter.com/kemystra"&gt;Twitter&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>100daysofcode</category>
      <category>beginners</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>Day 12: React &amp; Redux</title>
      <dc:creator>Kemystra</dc:creator>
      <pubDate>Sun, 17 Apr 2022 13:39:31 +0000</pubDate>
      <link>https://dev.to/kemystra/day-12-react-redux-190e</link>
      <guid>https://dev.to/kemystra/day-12-react-redux-190e</guid>
      <description>&lt;p&gt;&lt;em&gt;The Feyn- oops, too lazy today lol&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;react-redux&lt;/code&gt; Package
&lt;/h2&gt;

&lt;p&gt;We can finally use Redux with React after this long journey (of a few days 🤣), using the &lt;code&gt;react-redux&lt;/code&gt; package. This package includes several tools to improve the integration of Redux in React.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why?
&lt;/h2&gt;

&lt;p&gt;React's state is a mess when things get complex (remember that even if &lt;em&gt;one&lt;/em&gt; state updates, we have to write a boilerplate for ALL the other state). Redux is library that can manage state. You see where this is going?&lt;/p&gt;

&lt;h2&gt;
  
  
  Initiate the integration 🚀!
&lt;/h2&gt;

&lt;p&gt;First, we have to create a &lt;code&gt;Provider&lt;/code&gt;:&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;Provider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ReactRedux&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Provider&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Provider is a Redux wrapper for React that basically says: "I'm in charge of everything under here.". Simply wrap them around your &lt;em&gt;whole&lt;/em&gt; React app and you're set!&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;store&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Redux&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createStore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;reducer&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// In a render() method...&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Provider&lt;/span&gt; &lt;span class="nx"&gt;store&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;store&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;App&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;/Provider&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  This state only!
&lt;/h2&gt;

&lt;p&gt;We can restrict component's access to certain state only with the &lt;code&gt;mapStateToProps()&lt;/code&gt; function:&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;mapStateToProps&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;light&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;brightness&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can then access &lt;code&gt;brigtness&lt;/code&gt; inside state.&lt;/p&gt;

&lt;h2&gt;
  
  
  Afterwords
&lt;/h2&gt;

&lt;p&gt;Today's blog is short cause most of the time I tried to revise what I have learned about React, and they really put it to the test. Hopefully after getting my hands messy on them, the knowledge stuck.&lt;/p&gt;

&lt;p&gt;Anyway, good luck to others who are completing this challenge!&lt;/p&gt;

&lt;p&gt;Follow me on &lt;a href="https://github.com/Kemystra"&gt;Github&lt;/a&gt;!&lt;br&gt;
Also on &lt;a href="https://twitter.com/kemystra"&gt;Twitter&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>100daysofcode</category>
      <category>beginners</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>Day 11: Finished Redux</title>
      <dc:creator>Kemystra</dc:creator>
      <pubDate>Sat, 16 Apr 2022 14:24:19 +0000</pubDate>
      <link>https://dev.to/kemystra/day-11-finished-redux-467m</link>
      <guid>https://dev.to/kemystra/day-11-finished-redux-467m</guid>
      <description>&lt;p&gt;&lt;em&gt;The Fyeamn tehcinuqe syas taht taecinhg a sbujcet makes you better at it, which is what I'm trying to do here. You may correct me if you saw mistakes in this post&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Asynchronous Data
&lt;/h2&gt;

&lt;p&gt;Handling data that don't come on time is annoying (much like that one friend who's always late). Redux can't handle asynchronous data by itself. Instead you need yet &lt;em&gt;another&lt;/em&gt; software to achieve this, the aptly named &lt;em&gt;middleware&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Here, we will use Redux Thunk:&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;store&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Redux&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createStore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;reducerFunction&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ReduxThunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is to include Redux Thunk into our project.&lt;/p&gt;

&lt;p&gt;To update states asynchronously, we need to design a special action creator:&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;actionCreator&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;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dispatch&lt;/span&gt;&lt;span class="p"&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="c1"&gt;// You can dispatch loading action here&lt;/span&gt;
    &lt;span class="c1"&gt;// Here you can get the data&lt;/span&gt;
    &lt;span class="c1"&gt;// And then call an action, updating the state with the data&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;Note that the &lt;code&gt;dispatch&lt;/code&gt; argument is mandatory.&lt;/p&gt;

&lt;h2&gt;
  
  
  State immutability
&lt;/h2&gt;

&lt;p&gt;Redux DON'T force you to make the state immutable. However, you should.&lt;/p&gt;

&lt;p&gt;Keep this in mind when you are working with arrays or objects.&lt;/p&gt;

&lt;h2&gt;
  
  
  Afterwords
&lt;/h2&gt;

&lt;p&gt;I'm writing this during a very heavy rain, and I panicked a bit when the internet dropped 😵. Luckily it came back (Well, you won't be seeing this post if doesn't). &lt;/p&gt;

&lt;p&gt;I didn't learn a lot today, the circumstances of today really took a hit on my energy. Anyway, good luck to other people going through this challenge 😇. I need to catch my sleep 😴.&lt;/p&gt;

&lt;p&gt;Follow me on &lt;a href="https://github.com/Kemystra"&gt;Github&lt;/a&gt;!&lt;br&gt;
Also on &lt;a href="https://twitter.com/kemystra"&gt;Twitter&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>100daysofcode</category>
      <category>beginners</category>
      <category>javascript</category>
      <category>redux</category>
    </item>
  </channel>
</rss>
