<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[ReactPlay Blog]]></title><description><![CDATA[ReactPlay is an opensource platform to help you learn ReactJS faster with hands-on practice model. ReactPlay Blog is another step ahead to give you insights abo]]></description><link>https://blog.reactplay.io</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1656061331080/iG_xx3Z0i.png</url><title>ReactPlay Blog</title><link>https://blog.reactplay.io</link></image><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 17:19:44 GMT</lastBuildDate><atom:link href="https://blog.reactplay.io/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How to Authenticate Your React App Using Firebase]]></title><description><![CDATA[Authentication is a fundamental aspect of modern web and mobile applications. It ensures that users can securely access an app while protecting their data.
Firebase, a platform developed by Google, offers a simple and efficient way to add authenticat...]]></description><link>https://blog.reactplay.io/how-to-authenticate-your-react-app-using-firebase</link><guid isPermaLink="true">https://blog.reactplay.io/how-to-authenticate-your-react-app-using-firebase</guid><category><![CDATA[Firebase]]></category><category><![CDATA[Developer]]></category><category><![CDATA[authentication]]></category><category><![CDATA[General Programming]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Ijeoma Igboagu]]></dc:creator><pubDate>Wed, 16 Oct 2024 06:45:47 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1729033037677/4453ce47-e83d-4515-98cd-69349c118870.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Authentication is a fundamental aspect of modern web and mobile applications. It ensures that users can securely access an app while protecting their data.</p>
<p>Firebase, a platform developed by Google, offers a simple and efficient way to add authentication to your app.</p>
<p>In this article, I’ll walk you through the steps to authenticate your app using Firebase. Whether you're working on a web or mobile application, Firebase provides a straightforward way to integrate various authentication methods.</p>
<p>By the end of this article, you'll have a fully functional authentication system that allows users to sign up, sign in, and manage their accounts securely.</p>
<h2 id="heading-table-of-contents"><strong>Table of Contents</strong></h2>
<ul>
<li><p><a target="_blank" href="https://www.freecodecamp.org/news/authenticate-react-app-using-firebase/#heading-table-of-contents">Table of Contents</a></p>
</li>
<li><p><a target="_blank" href="https://www.freecodecamp.org/news/authenticate-react-app-using-firebase/#heading-prerequisites">Prerequisites</a></p>
</li>
<li><p><a target="_blank" href="https://www.freecodecamp.org/news/authenticate-react-app-using-firebase/#heading-why-use-firebase-for-authentication">Why Use Firebase for Authentication?</a></p>
</li>
<li><p><a target="_blank" href="https://www.freecodecamp.org/news/authenticate-react-app-using-firebase/#heading-step-1-how-to-set-up-a-firebase-project">Step 1: How to Set Up a Firebase Project</a></p>
</li>
<li><p><a target="_blank" href="https://www.freecodecamp.org/news/authenticate-react-app-using-firebase/#heading-step-2-how-to-install-firebase-in-your-project">Step 2: How to Install Firebase in Your Project</a></p>
</li>
<li><p><a target="_blank" href="https://www.freecodecamp.org/news/authenticate-react-app-using-firebase/#heading-step-3-how-to-initialize-firebase-in-your-app">Step 3: How to Initialize Firebase in Your App</a></p>
</li>
<li><p><a target="_blank" href="https://www.freecodecamp.org/news/authenticate-react-app-using-firebase/#heading-step-4-how-to-set-up-authentication-methods">Step 4: How to Set Up Authentication Methods</a></p>
</li>
<li><p><a target="_blank" href="https://www.freecodecamp.org/news/authenticate-react-app-using-firebase/#heading-authentication-method-using-google">Authentication Method Using Google</a></p>
</li>
<li><p><a target="_blank" href="https://www.freecodecamp.org/news/authenticate-react-app-using-firebase/#heading-step-5-how-to-upload-to-github">Step 5: How to Upload to GitHub</a></p>
</li>
<li><p><a target="_blank" href="https://www.freecodecamp.org/news/authenticate-react-app-using-firebase/#heading-conclusion">Conclusion</a></p>
</li>
</ul>
<h2 id="heading-prerequisites"><strong>Prerequisites</strong></h2>
<p>Before we begin, you need to have the following:</p>
<ul>
<li><strong>A Google Account</strong>: Firebase is a Google product, and you need a Google account to access the Firebase Console and use Firebase services. If you don’t have a Google account, <a target="_blank" href="https://support.google.com/mail/answer/56256?hl=en">you can create one here</a>.</li>
</ul>
<h2 id="heading-why-use-firebase-for-authentication"><strong>Why Use Firebase for Authentication?</strong></h2>
<p>Firebase Authentication provides backend services and easy-to-use SDKs to authenticate users to your app. It supports various authentication methods, including:</p>
<ul>
<li><p><strong>Email and password authentication</strong></p>
</li>
<li><p><strong>Google, Facebook, Twitter, and GitHub Authentication</strong></p>
</li>
<li><p><strong>Phone Number Authentication</strong></p>
</li>
<li><p><strong>Anonymous Authentication</strong></p>
</li>
</ul>
<p>These features make Firebase an excellent choice for developers who want to implement secure and reliable authentication without dealing with the complexities of building a custom authentication system.</p>
<p>Let’s get started with the setup!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1727802131211/b57dce67-663e-4c03-baa2-21668b543d68.jpeg" alt="picture displaying the start of the article" class="image--center mx-auto" /></p>
<h2 id="heading-step-1-how-to-set-up-a-firebase-project"><strong>Step 1: How to Set Up a Firebase Project</strong></h2>
<p>Before using Firebase Authentication, you need to set up a Firebase project.</p>
<p><strong>i. Create a Firebase Project</strong></p>
<ul>
<li>Go to the <a target="_blank" href="https://firebase.google.com/">Firebase Console.</a></li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1723410569746/560dfa39-e8d5-4b22-bb84-94946daeac08.png" alt="Firebase website" /></p>
<ul>
<li>Click "Add Project" and follow the on-screen instructions to create a new project.</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1727812540013/eceb505e-ea69-43f0-a845-ad26d86d5c26.gif" alt="Creating a project base" /></p>
<p>Once your project is created, you’ll be directed to the Firebase project dashboard.</p>
<p><strong>ii. Add Your App to the Project</strong></p>
<ul>
<li><p>In the Firebase console, click on the "Web" icon (&lt;/&gt;) to add a web app to your Firebase project.</p>
</li>
<li><p>Register your app with a nickname, and click "Register app."</p>
</li>
<li><p>You will be provided with a Firebase SDK snippet (Software Development Kit), which you'll need to add to your app.</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1723412408046/4bf3956f-1d7d-4dff-8a70-72a757c01d2b.gif" alt="Registering your project to firebase" /></p>
</li>
</ul>
<h2 id="heading-step-2-how-to-install-firebase-in-your-project"><strong>Step 2: How to Install Firebase in Your Project</strong></h2>
<p>To start with Firebase Authentication, you'll first need to install Firebase in your project. Here's how you can do it:</p>
<ul>
<li><p>In your code editor, open the terminal for your project.</p>
</li>
<li><p>Run the following command to install Firebase:</p>
</li>
</ul>
<pre><code class="lang-javascript">npm install firebase
</code></pre>
<p>This command will add Firebase to your project, allowing you to use its authentication and other features.</p>
<h2 id="heading-step-3-how-to-initialize-firebase-in-your-app"><strong>Step 3: How to Initialize Firebase in Your App</strong></h2>
<p>After installing Firebase, the next step is to initialize it in your project using the configuration snippet provided in the Firebase console, commonly referred to as the Firebase SDK snippet.</p>
<p><strong>To set this up:</strong></p>
<ol>
<li><p>Create a folder named <strong>config</strong> in your project directory.</p>
</li>
<li><p>Inside the folder, create a file called <strong>firebase.js</strong>.</p>
</li>
<li><p>Paste the SDK snippet you obtained from the Firebase console into the <strong>firebase.js</strong> file.</p>
</li>
</ol>
<p>Here’s what your project setup should look like:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1723459271302/4773d484-b5a2-4cbe-9626-76765cafd9b8.png" alt="Pasting the SDK in your project" /></p>
<p>This code initializes Firebase in your app, enabling you to utilize Firebase authentication and other services, such as Firebase storage, for managing your data.</p>
<p><strong>Note:</strong> Ensure you generate your unique application key for your application to function correctly.</p>
<h2 id="heading-step-4-how-to-set-up-authentication-methods"><strong>Step 4: How to Set Up Authentication Methods</strong></h2>
<p>Firebase supports multiple authentication methods, like using Google, Facebook, GitHub, and so on.</p>
<p>But let’s set up email and password authentication as an example:</p>
<ul>
<li><p>Go to "Authentication" in the left-hand menu in the Firebase console.</p>
</li>
<li><p>Click on the "Sign-in method" tab.</p>
</li>
<li><p>Enable "Email/Password" under the "Sign-in providers" section.</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1723457322104/6914efdc-87cf-4fce-b84f-bd407b6b4918.gif" alt="Authentication using email and password" /></p>
<p>  Now that you've enabled email/password authentication, you can create a sign-up and a sign-in function in your app.</p>
<p>  Let’s create a working example of a sign-up function:</p>
<ul>
<li><p>In your project, create a file named <strong>sign-up.jsx</strong>.</p>
</li>
<li><p>Import the function needed to create a user from Firebase. The function you'll use to create a user is <code>createUserWithEmailAndPassword</code>.</p>
</li>
<li><p>Before creating a user, make sure to import the auth instance that is initialized in <strong>firebase.js</strong> into the <strong>sign-up.jsx</strong> file.</p>
</li>
</ul>
</li>
</ul>
<pre><code class="lang-javascript">    <span class="hljs-keyword">import</span> { auth } <span class="hljs-keyword">from</span> <span class="hljs-string">'../../../config/firebase'</span>;
    <span class="hljs-keyword">import</span> { createUserWithEmailAndPassword } <span class="hljs-keyword">from</span> <span class="hljs-string">'firebase/auth'</span>;

    <span class="hljs-keyword">const</span> SignUp = <span class="hljs-function">() =&gt;</span> {
      <span class="hljs-comment">// To create the user with email and password</span>
      <span class="hljs-keyword">const</span> handleUser = <span class="hljs-keyword">async</span> (e) =&gt; {
        e.preventDefault();
        <span class="hljs-keyword">try</span> {
          <span class="hljs-keyword">await</span> createUserWithEmailAndPassword(auth, email, password);
          alert(<span class="hljs-string">'User created successfully'</span>);
        } <span class="hljs-keyword">catch</span> (err) {
          <span class="hljs-built_in">console</span>.error(err);
        }
      };

      <span class="hljs-comment">// ... (rest of your SignUp component)</span>
    };
</code></pre>
<p>In the return statement, I will use a form, so we need to import the <code>useState()</code> Hook to manage and track changes in the form's input fields.</p>
<pre><code class="lang-javascript">    &lt;div&gt;
      <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Register your Account<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span></span>
      <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">onSubmit</span>=<span class="hljs-string">{handleCreateUser}</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">label</span>&gt;</span>Name<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
            <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span>
            <span class="hljs-attr">id</span>=<span class="hljs-string">"name"</span>
            <span class="hljs-attr">name</span>=<span class="hljs-string">"name"</span>
            <span class="hljs-attr">value</span>=<span class="hljs-string">{name}</span>
            <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setName(e.target.value)}
          /&gt;
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

        <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">"email"</span>&gt;</span>Email<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
            <span class="hljs-attr">type</span>=<span class="hljs-string">"email"</span>
            <span class="hljs-attr">id</span>=<span class="hljs-string">"email"</span>
            <span class="hljs-attr">name</span>=<span class="hljs-string">"email"</span>
            <span class="hljs-attr">value</span>=<span class="hljs-string">{email}</span>
            <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setEmail(e.target.value)}
          /&gt;
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

        <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">"password"</span>&gt;</span>Password<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
            <span class="hljs-attr">type</span>=<span class="hljs-string">"password"</span>
            <span class="hljs-attr">id</span>=<span class="hljs-string">"password"</span>
            <span class="hljs-attr">name</span>=<span class="hljs-string">"password"</span>
            <span class="hljs-attr">value</span>=<span class="hljs-string">{password}</span>
            <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setPassword(e.target.value)}
          /&gt;
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

        <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">"confirm_password"</span> <span class="hljs-attr">className</span>=<span class="hljs-string">{styles.label}</span>&gt;</span>
            Confirm Password
          <span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
            <span class="hljs-attr">type</span>=<span class="hljs-string">"password"</span>
            <span class="hljs-attr">id</span>=<span class="hljs-string">"confirm_password"</span>
            <span class="hljs-attr">name</span>=<span class="hljs-string">"confirm_password"</span>
            <span class="hljs-attr">value</span>=<span class="hljs-string">{confirmPassword}</span>
            <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setConfirmPassword(e.target.value)}
          /&gt;
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

        <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"checkbox"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"terms"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"terms"</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"mr-2"</span> /&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">"terms"</span>&gt;</span>
              I agree to the <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"#"</span>&gt;</span>Terms and Conditions<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
            <span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
          <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

        <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"submit"</span>&gt;</span>Register<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span></span>
    &lt;/div&gt;
</code></pre>
<p>Putting all code together (<strong>Sign-up.jsx</strong>):</p>
<pre><code class="lang-javascript">
    <span class="hljs-keyword">import</span> { useState } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;
    <span class="hljs-keyword">import</span> { auth } <span class="hljs-keyword">from</span> <span class="hljs-string">'../../config/firebase'</span>;
    <span class="hljs-keyword">import</span> { createUserWithEmailAndPassword } <span class="hljs-keyword">from</span> <span class="hljs-string">'firebase/auth'</span>;

    <span class="hljs-keyword">const</span> SignUp = <span class="hljs-function">() =&gt;</span> {
      <span class="hljs-keyword">const</span> [name, setName] = useState(<span class="hljs-string">''</span>);
      <span class="hljs-keyword">const</span> [email, setEmail] = useState(<span class="hljs-string">''</span>);
      <span class="hljs-keyword">const</span> [password, setPassword] = useState(<span class="hljs-string">''</span>);
      <span class="hljs-keyword">const</span> [confirmPassword, setConfirmPassword] = useState(<span class="hljs-string">''</span>);

      <span class="hljs-keyword">const</span> handleCreateUser = <span class="hljs-keyword">async</span> (e) =&gt; {
        e.preventDefault();
        <span class="hljs-keyword">try</span> {
          <span class="hljs-keyword">await</span> createUserWithEmailAndPassword(auth, email, password);
          alert(<span class="hljs-string">'User created successfully'</span>);
        } <span class="hljs-keyword">catch</span> (error) {
          <span class="hljs-built_in">console</span>.log(error);
        }
      };

      <span class="hljs-keyword">return</span> (
        <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Register your Account<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">onSubmit</span>=<span class="hljs-string">{handleCreateUser}</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">label</span>&gt;</span>Name<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
                <span class="hljs-attr">type</span>=<span class="hljs-string">'text'</span>
                <span class="hljs-attr">id</span>=<span class="hljs-string">'name'</span>
                <span class="hljs-attr">name</span>=<span class="hljs-string">'name'</span>
                <span class="hljs-attr">value</span>=<span class="hljs-string">{name}</span>
                <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setName(e.target.value)}
              /&gt;
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

            <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">'email'</span>&gt;</span>Email<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
                <span class="hljs-attr">type</span>=<span class="hljs-string">'email'</span>
                <span class="hljs-attr">id</span>=<span class="hljs-string">'email'</span>
                <span class="hljs-attr">name</span>=<span class="hljs-string">'email'</span>
                <span class="hljs-attr">value</span>=<span class="hljs-string">{email}</span>
                <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setEmail(e.target.value)}
              /&gt;
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

            <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">'password'</span>&gt;</span>Password<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
                <span class="hljs-attr">type</span>=<span class="hljs-string">'password'</span>
                <span class="hljs-attr">id</span>=<span class="hljs-string">'password'</span>
                <span class="hljs-attr">name</span>=<span class="hljs-string">'password'</span>
                <span class="hljs-attr">value</span>=<span class="hljs-string">{password}</span>
                <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setPassword(e.target.value)}
              /&gt;
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

            <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">'confirm_password'</span>&gt;</span>
                Confirm Password
              <span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
                <span class="hljs-attr">type</span>=<span class="hljs-string">'password'</span>
                <span class="hljs-attr">id</span>=<span class="hljs-string">'confirm_password'</span>
                <span class="hljs-attr">name</span>=<span class="hljs-string">'confirm_password'</span>
                <span class="hljs-attr">value</span>=<span class="hljs-string">{confirmPassword}</span>
                <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setConfirmPassword(e.target.value)}
              /&gt;
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

            <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
                  <span class="hljs-attr">type</span>=<span class="hljs-string">'checkbox'</span>
                  <span class="hljs-attr">id</span>=<span class="hljs-string">'terms'</span>
                  <span class="hljs-attr">name</span>=<span class="hljs-string">'terms'</span>
                  <span class="hljs-attr">className</span>=<span class="hljs-string">'mr-2'</span>
                /&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">'terms'</span>&gt;</span>
                  I agree to the{' '}
                  <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">'#'</span>&gt;</span>
                    Terms and Conditions
                  <span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
                <span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
              <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

            <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">type</span>=<span class="hljs-string">'submit'</span>&gt;</span>Register<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
          <span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
      );
    };

    <span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> SignUp;
</code></pre>
<p>Now that you've created the sign-up function, it's time to add a sign-in function so users can log into your app.</p>
<p>Here's how to create a simple sign-in function:</p>
<ul>
<li><p>In your project, create a new file named <strong>sign-in.jsx</strong>.</p>
</li>
<li><p>Import the initialized <code>auth</code> instance from <strong>firebase.js</strong> into <strong>sign-in.jsx</strong>.</p>
</li>
<li><p>Use the <code>signInWithEmailAndPassword</code> function from Firebase to allow users to sign in.</p>
</li>
</ul>
<p>Here’s the structure for the sign-in function:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { useState } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;
<span class="hljs-keyword">import</span> { auth } <span class="hljs-keyword">from</span> <span class="hljs-string">'../../config/firebase'</span>;
<span class="hljs-keyword">import</span> { signInWithEmailAndPassword } <span class="hljs-keyword">from</span> <span class="hljs-string">'firebase/auth'</span>;

<span class="hljs-keyword">const</span> SignIn = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">const</span> [email, setEmail] = useState(<span class="hljs-string">''</span>);
  <span class="hljs-keyword">const</span> [password, setPassword] = useState(<span class="hljs-string">''</span>);

  <span class="hljs-keyword">const</span> handleSignIn = <span class="hljs-keyword">async</span> (e) =&gt; {
    e.preventDefault();
    <span class="hljs-keyword">try</span> {
      <span class="hljs-keyword">await</span> signInWithEmailAndPassword(auth, email, password);
      alert(<span class="hljs-string">'Signed in successfully'</span>);
    } <span class="hljs-keyword">catch</span> (error) {
      <span class="hljs-built_in">console</span>.error(error);
    }
  };

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Sign In<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">onSubmit</span>=<span class="hljs-string">{handleSignIn}</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">"email"</span>&gt;</span>Email<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
            <span class="hljs-attr">type</span>=<span class="hljs-string">"email"</span>
            <span class="hljs-attr">value</span>=<span class="hljs-string">{email}</span>
            <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setEmail(e.target.value)}
          /&gt;
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

        <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">"password"</span>&gt;</span>Password<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
            <span class="hljs-attr">type</span>=<span class="hljs-string">"password"</span>
            <span class="hljs-attr">value</span>=<span class="hljs-string">{password}</span>
            <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setPassword(e.target.value)}
          /&gt;
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

        <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"submit"</span>&gt;</span>Sign In<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
};

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> SignIn;
</code></pre>
<p>The visual display of the result from the code above both sign-up and sign-in</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1727813072045/5a91493d-69a0-4a90-98b2-61905b23e460.gif" alt="Visual Result of signup and signin put together" /></p>
<h2 id="heading-authentication-method-using-google"><strong>Authentication Method Using Google</strong></h2>
<p>As mentioned earlier, you can collect users' emails directly through a form before they use your app and other ways to authenticate the users.</p>
<p><strong>To use Google authentication:</strong></p>
<ul>
<li><p>In the Firebase console, navigate to "Authentication" in the left-hand menu.</p>
</li>
<li><p>Click on the "Sign-in method" tab.</p>
</li>
<li><p>Enable "Google" under the "Sign-in providers" section (for this tutorial, we'll stick with Google, though you can choose other providers).</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1727813344687/f1838b83-9af9-42a7-bf98-6a7d617cedc3.gif" alt="Enabling Google Auth" /></p>
<p>Now that you've enabled Google authentication, you can create a Google sign-up and sign-in function for your app.</p>
<p>Let's go through how to set up a Google sign-up function:</p>
<ul>
<li><p>First, create a file named <strong>Google.jsx</strong> in your project.</p>
</li>
<li><p>Import <code>auth</code> and <code>GoogleAuthProvider</code> from the <strong>firebase.js</strong> file</p>
</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-comment">// Import the functions you need from the SDKs you need</span>
<span class="hljs-keyword">import</span> { initializeApp } <span class="hljs-keyword">from</span> <span class="hljs-string">'firebase/app'</span>;
<span class="hljs-keyword">import</span> { getAuth, GoogleAuthProvider } <span class="hljs-keyword">from</span> <span class="hljs-string">'firebase/auth'</span>;


<span class="hljs-keyword">const</span> firebaseConfig = {
  <span class="hljs-attr">apiKey</span>: ....,
  <span class="hljs-attr">authDomain</span>: ....,
  <span class="hljs-attr">projectId</span>:.... ,
  <span class="hljs-attr">storageBucket</span>: .... ,
  <span class="hljs-attr">messagingSenderId</span>: .... ,
  <span class="hljs-attr">appId</span>: ....,
  <span class="hljs-attr">measurementId</span>: ....,
};
<span class="hljs-comment">// Initialize Firebase</span>
<span class="hljs-keyword">const</span> app = initializeApp(firebaseConfig);
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> auth= getAuth(app);
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> googleProvider = <span class="hljs-keyword">new</span> GoogleAuthProvider(app);
</code></pre>
<ul>
<li>Initialize the Google provider and export it for use in other parts of your application.</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { auth, googleProvider } <span class="hljs-keyword">from</span> <span class="hljs-string">'./firebase'</span>;  <span class="hljs-comment">// Adjust the path to your Firebase config file</span>
<span class="hljs-keyword">import</span> { signInWithPopup } <span class="hljs-keyword">from</span> <span class="hljs-string">'firebase/auth'</span>;
</code></pre>
<ul>
<li>Import the necessary Firebase function to authenticate a user. Use the <code>signInWithPopup</code> method to authenticate users with Google.</li>
</ul>
<p>While there are other authentication methods available, <code>signInWithPopup</code> is preferable as it keeps users within the app, avoiding the need to open a new browser tab.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> signInWithGoogle = <span class="hljs-keyword">async</span> () =&gt; {
  <span class="hljs-keyword">try</span> {
    <span class="hljs-keyword">await</span> signInWithPopup(auth, googleProvider);
    alert(<span class="hljs-string">'Signed in successfully with Google'</span>);
  } <span class="hljs-keyword">catch</span> (error) {
    <span class="hljs-built_in">console</span>.error(<span class="hljs-string">'Error signing in with Google'</span>, error);
  }
};
</code></pre>
<ul>
<li>In your return statement, create a button to trigger the Google sign-in.</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-keyword">return</span> (
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{signInWithGoogle}</span>&gt;</span>Sign in with Google<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
);
</code></pre>
<p>The visual display of the result from the code above:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1727813634035/14c00c73-f289-480a-a396-3abd839b3a75.gif" alt="Using signInWithPop()" /></p>
<p>Firebase allows you to sign users out of your application easily. Here's how you can implement a sign-out function:</p>
<ul>
<li><p>First, import the <code>signOut</code> function from Firebase.</p>
</li>
<li><p>Once imported, you can call <code>signOut</code> to log the user out of the app.</p>
</li>
</ul>
<p>Here’s a simple example:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { auth } <span class="hljs-keyword">from</span> <span class="hljs-string">'./config/firebase'</span>; <span class="hljs-comment">// Adjust the path based on your file structure</span>
<span class="hljs-keyword">import</span> { signOut } <span class="hljs-keyword">from</span> <span class="hljs-string">'firebase/auth'</span>;

<span class="hljs-keyword">const</span> handleSignOut = <span class="hljs-keyword">async</span> () =&gt; {
  <span class="hljs-keyword">try</span> {
    <span class="hljs-keyword">await</span> signOut(auth);
    alert(<span class="hljs-string">'User signed out successfully'</span>);
  } <span class="hljs-keyword">catch</span> (error) {
    <span class="hljs-built_in">console</span>.error(<span class="hljs-string">'Error signing out:'</span>, error);
  }
};
</code></pre>
<p>With this function, users can easily log out of the app.</p>
<p>In the return statement, you'll typically have a button that triggers the <strong>handleSignOut</strong> function when clicked.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">return</span> (
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Welcome to the app!<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{handleSignOut}</span>&gt;</span>Sign Out<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
</code></pre>
<p>The visual display of the result from the code above</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1727813736679/21c2162b-b376-43b7-87cb-242d78acef38.gif" alt="signOut() visual display" /></p>
<p>Make sure your Firebase project is configured to handle authentication correctly, including Google sign-in, to ensure a smooth sign-in and sign-out experience.</p>
<h2 id="heading-step-5-how-to-upload-to-github"><strong>Step 5: How to Upload to GitHub</strong></h2>
<p>Before pushing your project to GitHub, make sure to store your Firebase API key in an environment variable to keep it secure. This will prevent sensitive information from being exposed in your shared code.</p>
<p><strong>Creating a .env file</strong></p>
<ul>
<li>At the root of your application, create a <strong>.env</strong> file.</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1727813941388/5e647b8c-c76b-4671-b44b-21ac4dcddc89.png" alt="Storing the API keys in .env file" /></p>
<ul>
<li><p>Add your Firebase API key to the <strong>firebase.js</strong> file.</p>
</li>
<li><p>Use <code>import</code> or <code>process.env</code> to access your Firebase API key. Since the app was created with Vite, I used <code>import</code>.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1727814253953/514db02f-44f8-44fc-b03c-4cf77cb5c4ba.png" alt="Firebase file" /></p>
<ul>
<li>Finally, update your <strong>.gitignore</strong> file to include the <strong>.env</strong> file. This step also protects other sensitive files and directories, like <strong>node_modules</strong>.</li>
</ul>
<pre><code class="lang-javascript"># Logs
logs
node_modules
.env
</code></pre>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>In conclusion, this guide explains how to integrate Firebase Authentication into your app. Firebase simplifies adding authentication features such as email/password and Google login.</p>
<p>By setting up a Firebase project, installing, and initializing it in your app, you can efficiently build secure user sign-up and sign-in functionalities without the need to start from scratch or set up a server.</p>
<p>If you found this article helpful, share it with others who may find it interesting.</p>
<p>Stay updated with my projects by following me on <a target="_blank" href="https://https//twitter.com/ijaydimples">Twitter</a>, <a target="_blank" href="https://www.linkedin.com/in/ijeoma-igboagu/">LinkedIn</a> and <a target="_blank" href="https://github.com/ijayhub">GitHub</a>.</p>
<p>The code I used for this tutorial article can be found on my <a target="_blank" href="https://github.com/ijayhub/authentication-example-tutorial">GitHub</a>.</p>
<p>Thank you for reading.</p>
]]></content:encoded></item><item><title><![CDATA[How to Create Horizontal Parallax Scrolling using CSS and JavaScript]]></title><description><![CDATA[Hello there! My name is Shivam, and today, I will show you how to create this beautiful horizontal scrolling parallax effect with HTML, CSS, and JavaScript.

Wouldn't this look stunning on your blog or portfolio site?
To achieve this effect, we will ...]]></description><link>https://blog.reactplay.io/how-to-create-horizontal-parallax-scrolling-using-css-and-javascript</link><guid isPermaLink="true">https://blog.reactplay.io/how-to-create-horizontal-parallax-scrolling-using-css-and-javascript</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[CSS Animation]]></category><category><![CDATA[parallax]]></category><category><![CDATA[beginner]]></category><category><![CDATA[CSS3]]></category><dc:creator><![CDATA[Shivam Katare]]></dc:creator><pubDate>Thu, 12 Oct 2023 05:13:39 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1694156365798/15e41108-7898-4275-bfb1-c6e0e1634f8f.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello there! My name is Shivam, and today, I will show you how to create this beautiful horizontal scrolling parallax effect with HTML, CSS, and JavaScript.</p>
<p><a target="_blank" href="https://parallax-horizontal-scroll.vercel.app/"><img src="https://ik.imagekit.io/dnwefib6s4/Hashnode%20Covers%20(5).gif?updatedAt=1694121871938" alt class="image--center mx-auto" /></a></p>
<p>Wouldn't this look stunning on your blog or portfolio site?</p>
<p>To achieve <a target="_blank" href="https://parallax-horizontal-scroll.vercel.app/">this effect</a>, we will use:</p>
<p>• HTML - to add the images and content<br />• CSS - to style the horizontal scroll container and image wrappers<br />• JavaScript - to initialize Lightbox for image popups</p>
<p>Sound good? Open up your code editor, and let's get started! We'll be working with 2 files:</p>
<p><code>index.html</code>: Our HTML file with the scroll container and images<br /><code>style.css</code>: The CSS styles to position and transform the images on the scroll</p>
<p>Create these 2 files now so you're ready to follow along!</p>
<h2 id="heading-html-structure-setting-the-stage"><strong>HTML Structure: Setting the Stage</strong></h2>
<p>First, we'll set up the basic HTML structure. This is the foundation upon which our parallax scrolling masterpiece will be built.</p>
<pre><code class="lang-xml"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"en"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">"UTF-8"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"viewport"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"width=device-width, initial-scale=1.0"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Document<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
  <span class="hljs-comment">&lt;!-- Content  --&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p>Let's first import our CSS and a few font families that we will use to style our fonts.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1693864856194/49f79c18-b322-460e-85f9-73d117d384f3.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-xml"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"en"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">"UTF-8"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"viewport"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"width=device-width, initial-scale=1.0"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">"stylesheet"</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"style.css"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">href</span>=<span class="hljs-string">'https://fonts.googleapis.com/css?family=Merriweather:700'</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">'stylesheet'</span> <span class="hljs-attr">type</span>=<span class="hljs-string">'text/css'</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">href</span>=<span class="hljs-string">'https://fonts.googleapis.com/css?family=Merriweather:300italic'</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">'stylesheet'</span> <span class="hljs-attr">type</span>=<span class="hljs-string">'text/css'</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Parallax Scrolling<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
  <span class="hljs-comment">&lt;!-- Content  --&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p>We will create a main container (<code>&lt;div class="external"</code>) for the parallax scrolling page. This container holds everything we see on the webpage. 👇</p>
<pre><code class="lang-xml"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"en"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">"UTF-8"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"viewport"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"width=device-width, initial-scale=1.0"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">"stylesheet"</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"style.css"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">href</span>=<span class="hljs-string">'https://fonts.googleapis.com/css?family=Merriweather:700'</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">'stylesheet'</span> <span class="hljs-attr">type</span>=<span class="hljs-string">'text/css'</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">href</span>=<span class="hljs-string">'https://fonts.googleapis.com/css?family=Merriweather:300italic'</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">'stylesheet'</span> <span class="hljs-attr">type</span>=<span class="hljs-string">'text/css'</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Parallax Scrolling<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"external"</span>&gt;</span>
    <span class="hljs-comment">&lt;!-- All the cards will be  here --&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p>Within the <strong>main container</strong>, we will create a<code>&lt;div class="horizontal-scroll-wrapper"&gt;</code> that will enable horizontal scrolling. This is where the magic of parallax scrolling happens. 👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1693865495331/c6ef68dd-9b62-40e4-b068-6a0cc336c308.png" alt class="image--center mx-auto" /></p>
<p>Now, Each image is placed inside a <code>&lt;div class="img-wrapper"&gt;</code>. These image containers will move at different speeds, creating the parallax effect.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"external"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"horizontal-scroll-wrapper"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"img-wrapper"</span> &gt;</span>  <span class="hljs-comment">&lt;!--  &lt;-- Image Wrapper--&gt;</span>
        <span class="hljs-comment">&lt;!-- images will be here --&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
</code></pre>
<p>Now, within the <code>"img-wrapper"</code> we will use different classes like <code>"slower"</code>, <code>"faster"</code>, and <code>"vertical"</code> to control the speed and behavior of individual image containers.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1693866220322/56a822e4-bdf8-4829-a2bb-63df305317d4.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"external"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"horizontal-scroll-wrapper"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"img-wrapper slower"</span> &gt;</span>
        <span class="hljs-comment">&lt;!-- images will be here --&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"img-wrapper faster"</span>&gt;</span>
        <span class="hljs-comment">&lt;!-- images will be here --&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
</code></pre>
<p>Let's delve into the details of why these different classes are used:</p>
<ol>
<li><p><code>slower</code> <strong>Class</strong>: This class is applied to the first image container. It signifies that this image will scroll slower horizontally compared to other images. It adds a parallax effect by creating a visual difference in the scroll speed between this image and the rest of the content.</p>
</li>
<li><p><code>faster</code> <strong>Class</strong>: The second image container is assigned the <code>"faster"</code> class. This class suggests that this image will scroll faster horizontally. It moves ahead of the scrolling speed of the other content, enhancing the parallax scrolling effect.</p>
</li>
<li><p><code>vertical</code> <strong>Class</strong>: The third image container combines both the <code>"slower"</code> and <code>"vertical"</code> classes. It indicates that this image will not only scroll slower but also in a slightly vertical direction. This creates a more complex and intriguing parallax effect, as it deviates from the purely horizontal movement of the other images.</p>
</li>
</ol>
<p>You can add an image inside the image containers.👇</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"img-wrapper slower"</span> &gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://cdn.pixabay.com/photo/2013/07/18/20/26/sea-164989_640.jpg"</span> <span class="hljs-attr">target</span>=<span class="hljs-string">"_blank"</span>
     <span class="hljs-attr">rel</span>=<span class="hljs-string">"noopener"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.pixabay.com/photo/2013/07/18/20/26/sea-164989_640.jpg"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">""</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<details><summary>Note</summary><div data-type="detailsContent">Make sure that, <code>src</code> URL and <code>href</code> URLs are the same. Reason? We will cover it later in this blog.</div></details>

<p>Now, you can add more images inside all the <code>img-wrapper</code> containers.👇</p>
<pre><code class="lang-xml"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"en"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">"UTF-8"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"viewport"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"width=device-width, initial-scale=1.0"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">"stylesheet"</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"style.css"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">href</span>=<span class="hljs-string">'https://fonts.googleapis.com/css?family=Merriweather:700'</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">'stylesheet'</span> <span class="hljs-attr">type</span>=<span class="hljs-string">'text/css'</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">href</span>=<span class="hljs-string">'https://fonts.googleapis.com/css?family=Merriweather:300italic'</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">'stylesheet'</span> <span class="hljs-attr">type</span>=<span class="hljs-string">'text/css'</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Parallax Scrolling<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"external"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"horizontal-scroll-wrapper"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"img-wrapper slower"</span> &gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://cdn.pixabay.com/photo/2013/07/18/20/26/sea-164989_640.jpg"</span> <span class="hljs-attr">target</span>=<span class="hljs-string">"_blank"</span>
        <span class="hljs-attr">rel</span>=<span class="hljs-string">"noopener"</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.pixabay.com/photo/2013/07/18/20/26/sea-164989_640.jpg"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">""</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"img-wrapper faster"</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://cdn.pixabay.com/photo/2013/07/18/20/26/sea-164989_640.jpg"</span> <span class="hljs-attr">target</span>=<span class="hljs-string">"_blank"</span>
        <span class="hljs-attr">rel</span>=<span class="hljs-string">"noopener"</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.pixabay.com/photo/2013/07/18/20/26/sea-164989_640.jpg"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">""</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-comment">&lt;!-- add as many as you want --&gt;</span>

 <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p>Now, our HTML part is almost over. We need to add this heading👇 [It's an optional thing]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1694957549337/4423cd13-3fe6-48c2-9c7e-806d3773e16e.png" alt class="image--center mx-auto" /></p>
<hr />
<pre><code class="lang-xml"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"en"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">"UTF-8"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"viewport"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"width=device-width, initial-scale=1.0"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">"stylesheet"</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"style.css"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">href</span>=<span class="hljs-string">'https://fonts.googleapis.com/css?family=Merriweather:700'</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">'stylesheet'</span> <span class="hljs-attr">type</span>=<span class="hljs-string">'text/css'</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">href</span>=<span class="hljs-string">'https://fonts.googleapis.com/css?family=Merriweather:300italic'</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">'stylesheet'</span> <span class="hljs-attr">type</span>=<span class="hljs-string">'text/css'</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Parallax Scrolling<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"external"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"horizontal-scroll-wrapper"</span>&gt;</span>
    <span class="hljs-comment">&lt;!--image content --&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"scroll-info"</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"display: grid;"</span>&gt;</span>Scroll Down<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span> <span class="hljs-comment">&lt;!-- Scroll down text--&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<ul>
<li>The Output will look like this</li>
</ul>
<p><img src="https://ik.imagekit.io/dnwefib6s4/Hashnode%20Covers%20(6).gif?updatedAt=1694122342925" alt="Output will look like this" /></p>
<h2 id="heading-css-styles-crafting-the-parallax-magic"><strong>CSS Styles: Crafting the Parallax Magic</strong></h2>
<p>Let's delve into the CSS that transforms this HTML structure into a mesmerizing horizontal parallax scrolling experience. We'll break it down section by section.</p>
<h3 id="heading-global-styles">Global Styles</h3>
<pre><code class="lang-css"><span class="hljs-keyword">@import</span> url(<span class="hljs-attribute">https:</span>//fonts.googleapis.com/css?family=Raleway);

<span class="hljs-selector-tag">body</span> {
  <span class="hljs-attribute">font-family</span>: Hepta Slab, sans-serif;
  <span class="hljs-attribute">font-weight</span>: <span class="hljs-number">500</span>;
  <span class="hljs-attribute">background</span>: <span class="hljs-number">#000000</span>;
  <span class="hljs-attribute">color</span>: <span class="hljs-number">#5D4037</span>;
}

* {
  <span class="hljs-attribute">box-sizing</span>: border-box;
}

<span class="hljs-comment">/* Hide scrollbar */</span>
<span class="hljs-selector-pseudo">::-webkit-scrollbar</span> {
  <span class="hljs-attribute">width</span>: <span class="hljs-number">1px</span>;
  <span class="hljs-attribute">height</span>: <span class="hljs-number">1px</span>;
}

<span class="hljs-selector-pseudo">::-webkit-scrollbar-button</span> {
  <span class="hljs-attribute">width</span>: <span class="hljs-number">1px</span>;
  <span class="hljs-attribute">height</span>: <span class="hljs-number">1px</span>;
}
</code></pre>
<p>Here, we set up some global styles. We define the entire web page's font family, background color, and text color. We also hide the scrollbar for a cleaner look.</p>
<h3 id="heading-page-structure">Page Structure</h3>
<pre><code class="lang-css"><span class="hljs-selector-class">.external</span> {
  <span class="hljs-attribute">overflow</span>: hidden;
  <span class="hljs-attribute">height</span>: <span class="hljs-number">100vh</span>;
}

<span class="hljs-selector-class">.horizontal-scroll-wrapper</span> {
  <span class="hljs-attribute">display</span>: flex;
  <span class="hljs-attribute">flex-direction</span>: column;
  <span class="hljs-attribute">align-items</span>: center;
  <span class="hljs-attribute">width</span>: <span class="hljs-number">100vh</span>;
  <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(-<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translate3d</span>(<span class="hljs-number">0</span>, -<span class="hljs-number">100vh</span>, <span class="hljs-number">0</span>); <span class="hljs-comment">/* creates the horizontal scrolling effect */</span>
  <span class="hljs-attribute">transform-origin</span>: right top;
  <span class="hljs-attribute">overflow-y</span>: auto;
  <span class="hljs-attribute">overflow-x</span>: hidden;
  <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span>;
  <span class="hljs-attribute">height</span>: <span class="hljs-number">100vw</span>;
  <span class="hljs-attribute">perspective</span>: <span class="hljs-number">1px</span>;
  <span class="hljs-attribute">transform-style</span>: preserve-<span class="hljs-number">3</span>d;
  <span class="hljs-attribute">padding-bottom</span>: <span class="hljs-number">10rem</span>;
}
</code></pre>
<p>These styles set up the main structure of our horizontal scrolling page. We hide overflow, adjust dimensions, and use CSS transforms to create the horizontal scrolling effect.</p>
<h3 id="heading-image-containers-and-animation">Image Containers and Animation</h3>
<pre><code class="lang-css"><span class="hljs-selector-class">.img-wrapper</span> {
  <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">90deg</span>);
  <span class="hljs-attribute">display</span>: flex;
  <span class="hljs-attribute">align-items</span>: center;
  <span class="hljs-attribute">justify-content</span>: center;
  <span class="hljs-attribute">min-height</span>: <span class="hljs-number">40vh</span>;
  <span class="hljs-attribute">transform-origin</span>: <span class="hljs-number">50%</span> <span class="hljs-number">50%</span>;
  <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(.<span class="hljs-number">1px</span>) <span class="hljs-built_in">scale</span>(<span class="hljs-number">0.9</span>) <span class="hljs-built_in">translateX</span>(<span class="hljs-number">0px</span>) <span class="hljs-built_in">translateY</span>(-<span class="hljs-number">3vh</span>);
  <span class="hljs-attribute">transition</span>: <span class="hljs-number">1s</span>;
}

<span class="hljs-selector-class">.img-wrapper</span><span class="hljs-selector-pseudo">:hover</span> {
  <span class="hljs-attribute">min-height</span>: <span class="hljs-number">65vh</span>;
}

<span class="hljs-selector-class">.slower</span> {
  <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(-.<span class="hljs-number">2px</span>) <span class="hljs-built_in">scale</span>(<span class="hljs-number">1.1</span>) <span class="hljs-built_in">translateX</span>(<span class="hljs-number">0%</span>) <span class="hljs-built_in">translateY</span>(-<span class="hljs-number">10vh</span>);
}

<span class="hljs-selector-class">.slower1</span> {
  <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(-.<span class="hljs-number">25px</span>) <span class="hljs-built_in">scale</span>(<span class="hljs-number">1.05</span>) <span class="hljs-built_in">translateX</span>(<span class="hljs-number">0%</span>) <span class="hljs-built_in">translateY</span>(<span class="hljs-number">8vh</span>);
}

<span class="hljs-selector-class">.slower2</span> {
  <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(-.<span class="hljs-number">3px</span>) <span class="hljs-built_in">scale</span>(<span class="hljs-number">1.3</span>) <span class="hljs-built_in">translateX</span>(<span class="hljs-number">0%</span>) <span class="hljs-built_in">translateY</span>(<span class="hljs-number">2vh</span>);
}

<span class="hljs-selector-class">.slower-down</span> {
  <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(-.<span class="hljs-number">2px</span>) <span class="hljs-built_in">scale</span>(<span class="hljs-number">1.1</span>) <span class="hljs-built_in">translateX</span>(<span class="hljs-number">0%</span>) <span class="hljs-built_in">translateY</span>(<span class="hljs-number">16vh</span>);
}

<span class="hljs-comment">/* You can adjust these styles according to your own choice */</span>
<span class="hljs-comment">/* You can add more classes here. Like I did below */</span>👇

<span class="hljs-selector-class">.faster</span> {
  <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(.<span class="hljs-number">15px</span>) <span class="hljs-built_in">scale</span>(<span class="hljs-number">0.8</span>) <span class="hljs-built_in">translateX</span>(<span class="hljs-number">0%</span>) <span class="hljs-built_in">translateY</span>(<span class="hljs-number">14vh</span>);
}

<span class="hljs-selector-class">.faster1</span> {
  <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(.<span class="hljs-number">05px</span>) <span class="hljs-built_in">scale</span>(<span class="hljs-number">0.8</span>) <span class="hljs-built_in">translateX</span>(<span class="hljs-number">0%</span>) <span class="hljs-built_in">translateY</span>(<span class="hljs-number">10vh</span>);
}

<span class="hljs-selector-class">.fastest</span> {
  <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(.<span class="hljs-number">22px</span>) <span class="hljs-built_in">scale</span>(<span class="hljs-number">0.7</span>) <span class="hljs-built_in">translateX</span>(-<span class="hljs-number">10vh</span>) <span class="hljs-built_in">translateY</span>(-<span class="hljs-number">15vh</span>);
}

<span class="hljs-selector-class">.vertical</span> {
  <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(-.<span class="hljs-number">15px</span>) <span class="hljs-built_in">scale</span>(<span class="hljs-number">1.15</span>) <span class="hljs-built_in">translateX</span>(<span class="hljs-number">0%</span>) <span class="hljs-built_in">translateY</span>(<span class="hljs-number">0%</span>);
}

<span class="hljs-selector-class">.last</span> {
  <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(-.<span class="hljs-number">2px</span>) <span class="hljs-built_in">scale</span>(<span class="hljs-number">1.1</span>) <span class="hljs-built_in">translateX</span>(<span class="hljs-number">25vh</span>) <span class="hljs-built_in">translateY</span>(-<span class="hljs-number">8vh</span>);
}
</code></pre>
<p>In this section, we define the styles for image containers. Each image container has animation properties, creating the parallax effect as you scroll.</p>
<p>After all these styles, it will look like this 👇</p>
<p><img src="https://ik.imagekit.io/dnwefib6s4/Hashnode%20Covers%20(7).gif?updatedAt=1694123321933" alt class="image--center mx-auto" /></p>
<h3 id="heading-image-styles">Image Styles</h3>
<pre><code class="lang-css">
<span class="hljs-selector-class">.img-wrapper</span> <span class="hljs-selector-tag">a</span> {
  <span class="hljs-attribute">overflow</span>: hidden;
  <span class="hljs-attribute">display</span>: block;
  <span class="hljs-attribute">padding</span>: <span class="hljs-number">2px</span>;
  <span class="hljs-attribute">background</span>: <span class="hljs-number">#efecdb</span>;
  <span class="hljs-attribute">box-shadow</span>: <span class="hljs-number">0px</span> <span class="hljs-number">12px</span> <span class="hljs-number">50px</span> <span class="hljs-number">#5f2f1182</span>;
  <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">15px</span>;
}

<span class="hljs-selector-tag">img</span> {
  <span class="hljs-attribute">max-width</span>: <span class="hljs-number">45vh</span>;
  <span class="hljs-attribute">max-height</span>: <span class="hljs-number">50vh</span>;
  <span class="hljs-attribute">transition</span>: .<span class="hljs-number">5s</span>;
  <span class="hljs-attribute">vertical-align</span>: top;
  <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">15px</span>;
}

<span class="hljs-selector-tag">a</span><span class="hljs-selector-pseudo">:hover</span> <span class="hljs-selector-tag">img</span> {
  <span class="hljs-attribute">filter</span>: none;
}
</code></pre>
<p>Finally, we define styles for images and their behavior on hover, ensuring they fit seamlessly into our parallax scrolling experience.</p>
<h3 id="heading-style-title">Style Title</h3>
<p>At last, you can add styling to this title. 👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1694957522738/4069f4ee-4762-4371-8819-670219f47d28.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-css"><span class="hljs-selector-class">.scroll-info</span>,
<span class="hljs-selector-tag">header</span> {
  <span class="hljs-attribute">position</span>: absolute;
  <span class="hljs-attribute">left</span>: <span class="hljs-number">1rem</span>;
}

<span class="hljs-selector-tag">header</span> {
  <span class="hljs-attribute">bottom</span>: <span class="hljs-number">1rem</span>;
}

<span class="hljs-selector-class">.scroll-info</span> {
  <span class="hljs-attribute">top</span>: <span class="hljs-number">1rem</span>;
  <span class="hljs-attribute">font-family</span>: <span class="hljs-string">'Raleway'</span>;
  <span class="hljs-attribute">font-weight</span>: <span class="hljs-number">800</span>;
  <span class="hljs-attribute">font-size</span>: <span class="hljs-number">3rem</span>;
  <span class="hljs-attribute">color</span>: white;
}

<span class="hljs-selector-tag">a</span> {
  <span class="hljs-attribute">color</span>: inherit;
  <span class="hljs-attribute">font-weight</span>: <span class="hljs-number">500</span>;

}

<span class="hljs-selector-tag">h1</span> {
  <span class="hljs-attribute">font-weight</span>: <span class="hljs-number">300</span>;
  <span class="hljs-attribute">font-size</span>: <span class="hljs-number">1rem</span>;
}
</code></pre>
<h2 id="heading-enhancing-your-gallery-with-lightbox2">Enhancing Your Gallery with Lightbox2</h2>
<p>Now, let's enhance our image gallery using <a target="_blank" href="https://lokeshdhakar.com/projects/lightbox2/">Lightbox2</a>. This JavaScript library creates beautiful galleries, providing users with a seamless viewing experience. Here's how to integrate Lightbox2 into your project:</p>
<h3 id="heading-step-1-include-jquery-and-lightbox2-libraries">Step 1: Include jQuery and Lightbox2 Libraries</h3>
<p>Lightbox2 relies on jQuery, so make sure to include both jQuery and Lightbox2 libraries in your HTML:</p>
<pre><code class="lang-xml"><span class="hljs-comment">&lt;!-- Include jQuery --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://code.jquery.com/jquery-3.6.0.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>

<span class="hljs-comment">&lt;!-- Include Lightbox2 JavaScript (after jQuery) --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.3/js/lightbox.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>

<span class="hljs-comment">&lt;!-- Include Lightbox2 CSS --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.3/css/lightbox.min.css"</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">"stylesheet"</span>&gt;</span>
</code></pre>
<p>Here's why we used each of these:</p>
<ul>
<li><p><strong>jQuery</strong>: Lightbox2 relies on jQuery for certain functionalities. jQuery simplifies JavaScript tasks, making it easier to work with the Document Object Model (DOM) and handle events.</p>
</li>
<li><p><strong>Lightbox2 JavaScript</strong>: This script is the core of Lightbox2, providing the functionality for creating the lightbox effect.</p>
</li>
<li><p><strong>Lightbox2 CSS</strong>: The included CSS file styles the lightbox components, such as the overlay, close button, and image display, to ensure a visually appealing presentation.</p>
</li>
</ul>
<h3 id="heading-step-2-configure-lightbox-options">Step 2: Configure Lightbox Options</h3>
<p>Once you've included the necessary libraries, it's time to configure Lightbox2's options to customize the behavior and appearance of your Lightbox gallery:</p>
<pre><code class="lang-javascript">&lt;script&gt;
    lightbox.option({
        <span class="hljs-string">'resizeDuration'</span>: <span class="hljs-number">200</span>,
        <span class="hljs-string">'wrapAround'</span>: <span class="hljs-literal">true</span>
    });
&lt;/script&gt;
</code></pre>
<p>Here's what each option does:</p>
<ul>
<li><p><code>'resizeDuration'</code>: This option controls the duration (in milliseconds) of the image resizing animation when a user clicks on an image to open it in the lightbox. A value of 200 milliseconds provides a smooth and visually pleasing transition.</p>
</li>
<li><p><code>'wrapAround'</code>: When set to <code>true</code>, this option allows us to loop through images in our gallery. When we reach the last image and click 'next,' we'll go back to the first image, creating a seamless loop. This feature improves user navigation through multiple images.</p>
</li>
</ul>
<h3 id="heading-step-3-enhance-image-links-for-lightbox2">Step 3: Enhance Image Links for Lightbox2</h3>
<p>To make Lightbox2 work seamlessly, ensure that the <code>href</code> attribute of your image links matches the <code>src</code> attribute of the corresponding images. Additionally, include <code>data-lightbox</code> and <code>data-title</code> attributes in your links. These attributes tell Lightbox2 what image to display and provide a title for it. Here's an example:</p>
<pre><code class="lang-javascript">&lt;div <span class="hljs-class"><span class="hljs-keyword">class</span></span>=<span class="hljs-string">"img-wrapper slower"</span>&gt;
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://cdn.pixabay.com/photo/2014/01/22/19/44/flower-field-250016_640.jpg"</span> <span class="hljs-attr">target</span>=<span class="hljs-string">"_blank"</span>
    <span class="hljs-attr">rel</span>=<span class="hljs-string">"noopener"</span> <span class="hljs-attr">data-lightbox</span>=<span class="hljs-string">"my-image"</span> <span class="hljs-attr">data-title</span>=<span class="hljs-string">"Beautiful Flower Field"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.pixabay.com/photo/2014/01/22/19/44/flower-field-250016_640.jpg"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">"Flower Field"</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
</code></pre>
<p>In this example, the <code>href</code> and <code>src</code> attributes have the same URL, ensuring Lightbox2 displays the correct image. The <code>data-lightbox</code> attribute with the value <code>"my-image"</code> identifies this image for Lightbox2, and the <code>data-title</code> attribute provides a title for the image.</p>
<p>Now, the complete gallery will look like this👇</p>
<p><img src="https://ik.imagekit.io/dnwefib6s4/Hashnode%20Covers%20(5).gif?updatedAt=1694121871938" alt class="image--center mx-auto" /></p>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>And with that, we've built a fully functional horizontal parallax image slider using HTML, CSS, and JS!</p>
<p>Thanks for reading it. I hope it was insightful. All the source code used in this article is in my <a target="_blank" href="https://github.com/Shivam-Katare/ParallaxHorizontalScroll"><strong>GitHub repository</strong></a>.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://github.com/Shivam-Katare/ParallaxHorizontalScroll">https://github.com/Shivam-Katare/ParallaxHorizontalScroll</a></div>
<p> </p>
<p>Follow <a target="_blank" href="https://blog.reactplay.io/">ReactPlay blogs</a> and read more interesting and insightful content.</p>
<p>If you liked the article, please post likes 👍, give it a ⭐, and share it in your circles.</p>
<p>Let's connect. I share content related to web development, technical writing, and Open Source.👇</p>
<ul>
<li><p><a target="_blank" href="https://twitter.com/shivamkatare_27"><strong>Twitter</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.showwcase.com/shivam-katare"><strong>Showwcase</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.linkedin.com/in/shivam-katare-aa80b218b/"><strong>LinkedIn</strong></a></p>
</li>
</ul>
<p>Thanks for reading 😊</p>
]]></content:encoded></item><item><title><![CDATA[Using Fontsource With 11ty]]></title><description><![CDATA[Dealing with fonts can get quite overwhelming. For quite some time, I was searching for a way to self-host google fonts because the google fonts API's network request increased the render-blocking time more than I expected.
I stumbled upon fontsource...]]></description><link>https://blog.reactplay.io/using-fontsource-with-11ty-murtuza</link><guid isPermaLink="true">https://blog.reactplay.io/using-fontsource-with-11ty-murtuza</guid><category><![CDATA[coding]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[fonts]]></category><category><![CDATA[CSS]]></category><dc:creator><![CDATA[Murtuzaali Surti]]></dc:creator><pubDate>Fri, 06 Oct 2023 18:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1696665563285/9d6df729-9897-4e73-bf69-8bdf1100663b.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Dealing with fonts can get quite overwhelming. For quite some time, I was searching for a way to self-host google fonts because the google fonts API's network request increased the render-blocking time more than I expected.</p>
<p>I stumbled upon <a target="_blank" href="http://fontsource.org">fontsource.org</a> the other day and I found the idea of installing fonts from npm packages appealing.</p>
<p>At first, I used it in my <a target="_blank" href="https://murtuzaalisurti.github.io">personal site</a> built with <a target="_blank" href="https://astro.build">Astro</a>. The process was incredibly simple. You just have to <a target="_blank" href="https://docs.astro.build/en/guides/fonts/#using-fontsource">import fonts</a> in your base layout file and that's it. You are ready to use it in your CSS!</p>
<pre><code class="lang-bash">npm i @fontsource/poppins @fontsource/nunito
</code></pre>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> <span class="hljs-string">"@fontsource/poppins"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">"@fontsource/nunito/400.css"</span>;
</code></pre>
<p>I thought what if I could use this in my <a target="_blank" href="https://syntackle.live">11ty blog</a> too. The next immediate thing which came to mind was to use 'vite' because it can bundle those fonts for me just like Astro.</p>
<p>I decided to use <a target="_blank" href="https://slinkity.dev/">slinkity</a>. You can call slinkity as an extension for 11ty projects. It adds more features to the table by post-processing your 11ty build output.</p>
<p>Slinkity uses <a target="_blank" href="https://vitejs.dev/">vite</a> for bundling which is great, but it became a problem for me. I have a relatively old and large project with some custom configurations which came in the way of how vite does things, so migrating to vite resulted in a mess. The migration needs more time. I decided to take another approach which might be not so good.</p>
<h2 id="heading-using-rollup">Using Rollup</h2>
<p><a target="_blank" href="https://rollupjs.org/guide/en/">Rollup</a> is a javascript bundler you can use to bundle your modules.</p>
<pre><code class="lang-bash">npm install rollup --save-dev
</code></pre>
<p>I created a rollup config file, named <code>rollup.config.mjs</code> at the root of the project.</p>
<pre><code class="lang-js"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> [
    {
        <span class="hljs-attr">input</span>: <span class="hljs-string">"src/js/combine.js"</span>,
        <span class="hljs-attr">output</span>: {
            <span class="hljs-attr">file</span>: <span class="hljs-string">"src/js/minified/index.bundle.js"</span>,
            <span class="hljs-attr">sourcemap</span>: <span class="hljs-literal">false</span>,
        }
    }
];
</code></pre>
<p>The idea is to import the fonts just like I did in astro, in a javascript file and then extract css from it in order to copy it in the styles folder.</p>
<p>Inside the <code>combine.js</code> file, I imported some fonts.</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> <span class="hljs-string">"@fontsource/nunito"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">"@fontsource/poppins"</span>;
</code></pre>
<p>To extract css, I used the <a target="_blank" href="https://github.com/egoist/rollup-plugin-postcss">postcss rollup plugin</a> and the <a target="_blank" href="https://github.com/vladshcherbin/rollup-plugin-copy">rollup copy plugin</a> to copy the generated css file to the desired directory. I had to use rollup-plugin-copy because of <a target="_blank" href="https://github.com/egoist/rollup-plugin-postcss/issues/250">this issue</a>.</p>
<p>Installed the following dependencies:</p>
<pre><code class="lang-bash">npm i rollup-plugin-postcss rollup-plugin-copy @rollup/plugin-node-resolve --save-dev
</code></pre>
<p>The postcss plugin will extract the styles from the javascript file into a new CSS file.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { nodeResolve } <span class="hljs-keyword">from</span> <span class="hljs-string">"@rollup/plugin-node-resolve"</span>;
<span class="hljs-keyword">import</span> postcss <span class="hljs-keyword">from</span> <span class="hljs-string">"rollup-plugin-postcss"</span>;
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> [
    {
        <span class="hljs-attr">input</span>: <span class="hljs-string">"src/js/combine.js"</span>,
        <span class="hljs-attr">output</span>: {
            <span class="hljs-attr">file</span>: <span class="hljs-string">"src/js/minified/index.bundle.js"</span>,
            <span class="hljs-attr">sourcemap</span>: <span class="hljs-literal">false</span>,
        }
        <span class="hljs-attr">plugins</span>: [
            nodeResolve(),
            postcss({
                <span class="hljs-attr">extract</span>: <span class="hljs-literal">true</span>, <span class="hljs-comment">// no way to move output to another folder https://github.com/egoist/rollup-plugin-postcss/issues/250</span>
                <span class="hljs-attr">minimize</span>: <span class="hljs-literal">true</span>,
            })
        ],
    }
];
</code></pre>
<p>The next step is to move the CSS file to the desired location because the extracted CSS file will be in the same directory as of the javascript file and you can't specify a location outside the parent folder due to a <a target="_blank" href="https://github.com/egoist/rollup-plugin-postcss/issues/250">bug in the postcss plugin</a>.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { nodeResolve } <span class="hljs-keyword">from</span> <span class="hljs-string">"@rollup/plugin-node-resolve"</span>;
<span class="hljs-keyword">import</span> postcss <span class="hljs-keyword">from</span> <span class="hljs-string">"rollup-plugin-postcss"</span>;
<span class="hljs-keyword">import</span> copy <span class="hljs-keyword">from</span> <span class="hljs-string">"rollup-plugin-copy"</span>;
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> [
    {
        <span class="hljs-attr">input</span>: <span class="hljs-string">"src/js/combine.js"</span>,
        <span class="hljs-attr">output</span>: {
            <span class="hljs-attr">file</span>: <span class="hljs-string">"src/js/minified/index.bundle.js"</span>,
            <span class="hljs-attr">sourcemap</span>: <span class="hljs-literal">false</span>,
        }
        <span class="hljs-attr">plugins</span>: [
            nodeResolve(),
            postcss({
                <span class="hljs-attr">extract</span>: <span class="hljs-literal">true</span>, <span class="hljs-comment">// no way to move output to another folder https://github.com/egoist/rollup-plugin-postcss/issues/250</span>
                <span class="hljs-attr">minimize</span>: <span class="hljs-literal">true</span>,
            }),
            copy({
                <span class="hljs-attr">targets</span>: [
                    {
                        <span class="hljs-attr">src</span>: <span class="hljs-string">"src/js/minified/index.bundle.css"</span>,
                        <span class="hljs-attr">dest</span>: <span class="hljs-string">"src/styles/minified"</span>,
                        <span class="hljs-attr">rename</span>: <span class="hljs-string">"fonts.bundle.css"</span>,
                    },
                ],
                <span class="hljs-attr">verbose</span>: <span class="hljs-literal">true</span>,
                <span class="hljs-attr">hook</span>: <span class="hljs-string">"writeBundle"</span>,
            })
        ],
    }
];
</code></pre>
<p>I am running the copy plugin after all the bundles are written and that's why you see the <code>hook: "writeBundle"</code> build hook specified for the copy plugin.</p>
<p>Run rollup using this command:</p>
<pre><code class="lang-bash">npx rollup --bundleConfigAsCjs -c
</code></pre>
<p>The font CSS is ready to use, right? No. There is still one problem.</p>
<p>This is how the generated CSS looks:</p>
<pre><code class="lang-css"><span class="hljs-keyword">@font-face</span>{<span class="hljs-attribute">font-display</span>:swap;<span class="hljs-attribute">font-family</span>:Nunito;<span class="hljs-attribute">font-style</span>:normal;<span class="hljs-attribute">font-weight</span>:<span class="hljs-number">400</span>;<span class="hljs-attribute">src</span>:<span class="hljs-built_in">url</span>(files/nunito-cyrillic-ext-<span class="hljs-number">400</span>-normal.woff2) <span class="hljs-built_in">format</span>(<span class="hljs-string">"woff2"</span>),<span class="hljs-built_in">url</span>(files/nunito-all-<span class="hljs-number">400</span>-normal.woff) <span class="hljs-built_in">format</span>(<span class="hljs-string">"woff"</span>);<span class="hljs-attribute">unicode-range</span>:u+<span class="hljs-number">0460</span>-<span class="hljs-number">052</span>f,u+<span class="hljs-number">1</span>c80-<span class="hljs-number">1</span>c88,u+<span class="hljs-number">20</span>b4,u+<span class="hljs-number">2</span>de0-<span class="hljs-number">2</span>dff,u+a640-a69f,u+fe2e-fe2f}<span class="hljs-keyword">@font-face</span>{<span class="hljs-attribute">font-display</span>:swap;<span class="hljs-attribute">font-family</span>:Nunito;<span class="hljs-attribute">font-style</span>:normal;<span class="hljs-attribute">font-weight</span>:<span class="hljs-number">400</span>;<span class="hljs-attribute">src</span>:<span class="hljs-built_in">url</span>(files/nunito-cyrillic-<span class="hljs-number">400</span>-normal.woff2) <span class="hljs-built_in">format</span>(<span class="hljs-string">"woff2"</span>),<span class="hljs-built_in">url</span>(files/nunito-all-<span class="hljs-number">400</span>-normal.woff) <span class="hljs-built_in">format</span>(<span class="hljs-string">"woff"</span>);<span class="hljs-attribute">unicode-range</span>:u+<span class="hljs-number">0301</span>,u+<span class="hljs-number">0400</span>-<span class="hljs-number">045</span>f,u+<span class="hljs-number">0490</span>-<span class="hljs-number">0491</span>,u+<span class="hljs-number">04</span>b0-<span class="hljs-number">04</span>b1,u+<span class="hljs-number">2116</span>}
</code></pre>
<p>If you look closely at the src url, you will find that the files which the url is referring to are not present in our directory. Yes, the actual font files.</p>
<p>I used <code>addPassthroughCopy()</code> in 11ty to copy the required font files from node_modules to the output directory as per the url specified in the font stylesheet.</p>
<pre><code class="lang-javascript">eleventyConfig.addPassthroughCopy({<span class="hljs-string">'./node_modules/@fontsource/poppins/files/*.woff2'</span>: <span class="hljs-string">'styles/files'</span>})
</code></pre>
<p>Copy the required files to the output folder and the fonts are ready to be used.</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">font-family</span>: "<span class="hljs-selector-tag">Poppins</span>", "<span class="hljs-selector-tag">Nunito</span>", <span class="hljs-selector-tag">sans-serif</span>;
</code></pre>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Is this a good solution? I don't know. For me, it's more of a hack than a solution and I think there's a better way. Maybe, all we need is an 11ty plugin :)</p>
<blockquote>
<p><em>This post was originally published in</em> <a target="_blank" href="https://syntackle.live/blog/using-fontsource-with-11ty-FUzgft/"><em>Syntackle</em></a><em>.</em></p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[How to contribute to Hacktoberfest 2023 through ReactPlay?]]></title><description><![CDATA[Our favorite month is here! And we have some amazing activities planned for our community 🤩
Yes, you are right. We are talking about Hacktoberfest! In this blog, we want to cover various ways you can participate in Hacktoberfest through the ReactPla...]]></description><link>https://blog.reactplay.io/hacktoberfest-2023</link><guid isPermaLink="true">https://blog.reactplay.io/hacktoberfest-2023</guid><category><![CDATA[#hacktoberfest ]]></category><category><![CDATA[Hacktoberfest2023]]></category><category><![CDATA[Open Source]]></category><category><![CDATA[ReactPlay]]></category><dc:creator><![CDATA[Kaushal Joshi]]></dc:creator><pubDate>Sun, 01 Oct 2023 05:47:29 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1696138998434/3435ddc4-3c66-4604-bb96-290bb2a5ae7d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Our favorite month is here! And we have some amazing activities planned for our community 🤩</p>
<p>Yes, you are right. We are talking about <a target="_blank" href="https://hacktoberfest.com/"><strong>Hacktoberfest</strong></a>! In this blog, we want to cover various ways you can participate in Hacktoberfest through the ReactPlay community.</p>
<h2 id="heading-what-is-hacktoberfest">What is Hacktoberfest?</h2>
<p>Simply put, Hacktoberfest is an ode to open-source. It's a month-long event dedicated to everything open-source. The developer community celebrates open-source projects, its maintainers, and contributors and organizes various events and activities. The main purpose of Hacktoberfest is to embrace open-source projects and their maintainers, encourage new open-source contributors to participate, and foster collaboration, growth, and innovation in the developer community.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1696082590627/f99e6759-34e9-4171-9829-cf865288d14c.png" alt class="image--center mx-auto" /></p>
<p><strong>DigitalOcean</strong> and its partners organize Hacktoberfest every year in October. This year, DigitalOcean is organizing Hacktoberfest with <strong>ILLA Cloud</strong> and <strong>Appwrite</strong>. And this year, it's special. Why you ask? 2023 is the 10th anniversary of Hacktoberfest! For the last decade, DigitalOcean and its partners have been embracing open-source, and introducing it to more and more developers!</p>
<p>We wrote a blog last year that explains everything about Hacktoberfest in detail. If you are still curious, make sure you give it a read.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://reactplay.hashnode.dev/hacktoberfest-101-with-reactplay">https://reactplay.hashnode.dev/hacktoberfest-101-with-reactplay</a></div>
<p> </p>
<h2 id="heading-hacktoberfest-x-reactplay">Hacktoberfest x ReactPlay</h2>
<p>As an open-source community, we <strong>LOVE</strong> Hacktoberfest. We met so many amazing contributors through Hacktoberfest, that we could reach new heights and achieve great milestones because. Last year, we conducted our first edition of <a target="_blank" href="https://reactplay.hashnode.dev/announcing-hack-r-play-hackathon-from-react-play">Hack-R-Play</a> in Hacktoberfest.</p>
<p>We are (of course!) participating in Hacktoberfest 2023 as well. And this year, to make its 10th anniversary special, we have super-duper plans. In Hacktoberfest 2023, ReactPlay will also accept low-code and no-code participation as valid Hacktoberfest participation.</p>
<p>Our last year's blog dives deep into ReactPlay's Hacktoberfest participation and the different types of contributions we support.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://reactplay.hashnode.dev/no-codelow-code-contributions-to-open-source-in-hactoberfest">https://reactplay.hashnode.dev/no-codelow-code-contributions-to-open-source-in-hactoberfest</a></div>
<p> </p>
<p>In this blog, we want to cover every possible domain in which you can contribute to the ReactPlay community at Hacktoberfest.</p>
<h2 id="heading-how-developers-can-participate-in-hacktoberfest">How developers can participate in Hacktoberfest?</h2>
<p>There are multiple ways to contribute to ReactPlay if you are a developer. We have a whole bunch of issues ready for you in two of our GitHub repositories. Here are four ways you can do so:</p>
<ul>
<li><p><strong>Create a new play</strong>: The easiest way to contribute is to create a new play. <a target="_blank" href="https://docs.reactplay.io/How-To-Guides/how-to-create-play">This guide</a> will help you create your first play on ReactPlay.</p>
</li>
<li><p><strong>Resolve a bug</strong>: You can check the opened issues in both repositories and search for bugs you can resolve. Alternatively, if you find any unnoticed bug, feel free to resolve it too.</p>
</li>
<li><p><strong>Add a feature</strong>: Similar to the last one, if you come across any feature request in opened issues, or have a new feature that you want to implement by yourself, you can do that as well.</p>
</li>
<li><p><strong>Enhance the existing codebase</strong>: Also, you can improve the existing project by working on existing modules that need an update.</p>
</li>
</ul>
<h3 id="heading-open-issues-in-react-play">Open issues in <code>react-play</code></h3>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://github.com/reactplay/react-play/issues?q=is%3Aopen+is%3Aissue+label%3Ahacktoberfest">https://github.com/reactplay/react-play/issues?q=is%3Aopen+is%3Aissue+label%3Ahacktoberfest</a></div>
<p> </p>
<h3 id="heading-open-issues-in-docs">Open issues in <code>docs</code></h3>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://github.com/reactplay/docs/issues?q=is%3Aopen+is%3Aissue+label%3Ahacktoberfest">https://github.com/reactplay/docs/issues?q=is%3Aopen+is%3Aissue+label%3Ahacktoberfest</a></div>
<p> </p>
<h2 id="heading-how-writes-can-participate-in-hacktoberfest">How writes can participate in Hacktoberfest?</h2>
<p>If you are a writer you can contribute in two ways: <strong>blogs</strong> or <strong>documentation</strong>. <a target="_blank" href="https://blog.reactplay.io">ReactPlay blog</a> is an initiative to encourage developers to get better at technical writing. You can write a blog about the web, open-source, technology, your experiences, and anything you want to share with the world. If you are not a skilled technical writer and still want to give it a shot, we can help you to get better by proofreading and editing your blog.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://blog.reactplay.io/">https://blog.reactplay.io/</a></div>
<p> </p>
<blockquote>
<p>For the period of Hacktoberfest 2023, the blog you contribute with must be original, and should not have been published anywhere, including your personal blog.</p>
</blockquote>
<p>The second way is <strong>documentation</strong>. You can write documentation on various areas related to ReactPlay. Feel free to check out <a target="_blank" href="https://github.com/reactplay/docs/issues?q=is%3Aopen+is%3Aissue+label%3Ahacktoberfest">opened issues</a> or join the dedicated docs channel to get a better understanding of this.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://github.com/reactplay/docs/issues?q=is%3Aopen+is%3Aissue+label%3Ahacktoberfest">https://github.com/reactplay/docs/issues?q=is%3Aopen+is%3Aissue+label%3Ahacktoberfest</a></div>
<p> </p>
<h2 id="heading-how-public-speakers-can-participate-in-hacktoberfest">How public speakers can participate in Hacktoberfest?</h2>
<p>Public speaking is not everyone's cup of tea! It's amazing that you are into public speaking, or at least want to get into it. Don't worry, we have something for you...</p>
<h3 id="heading-host-an-event">Host an event</h3>
<p>If you are a college student part of a college community, a BootCamp or course attendee, or active in any online or in-person communities, you can host an event. The event can be either in-person or online, that's totally up to you. The event can educate others about open-source and web dev through ReactPlay.</p>
<h3 id="heading-organize-a-workshopseminar">Organize a workshop/seminar</h3>
<p>If you want to go one step further and get your (and attendees') hands dirty, you can organize a workshop as well. Just like the event, the workshop can be either online or in-person. The workshop can dive deep into open-source, web dev technologies and provide hands-on practical learnings to attendees. You can use ReactPlay as a tool to teach others how things work.</p>
<h3 id="heading-nominate-yourself-for-open-mic">Nominate yourself for Open Mic</h3>
<p>Open Mic is our initiative that brings out the inner public speaker of you. We host Open Mic on Fridays where you can talk about technical things you are good at. It's okay if you haven't given a talk or are afraid to do so. All you need is a good topic that you are interested in talking about, and a little courage to speak to the camera. Everything else will come on its own!</p>
<p>We have successfully hosted four Open Mic sessions until now. If you want to give a talk, you can nominate yourself in the following form:</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://docs.google.com/forms/d/1y77dsvL2Wew3gZfZxhOdsq3Pc6bH4imbo7znRN-lueU/viewform?edit_requested=true">https://docs.google.com/forms/d/1y77dsvL2Wew3gZfZxhOdsq3Pc6bH4imbo7znRN-lueU/viewform?edit_requested=true</a></div>
<p> </p>
<h3 id="heading-give-a-talk">Give a talk</h3>
<p>Last but not least, if you are into public speaking, you can give a talk. The talk can be at a conference, seminar, workshop, event, online event, community meetup, or even Twitter (X) spaces as well. The talk can be about anything regarding open-source, web dev, and mention ReactPlay to some extent.</p>
<h3 id="heading-publish-a-podcast">Publish a podcast</h3>
<p>If you host a podcast or know someone who hosts podcasts and is interested in participating in Hacktoberfest, you can collaborate to record a podcast session. You can invite someone from the ReactPlay community as well. We would love to be a part of that.</p>
<h2 id="heading-a-few-things-to-remember">A few things to remember</h2>
<p>There are plenty of opportunities for you to participate in Hacktobefest whether or not you are a developer. However, there are some things that you must remember before contributing to any open-source project like ReactPlay during Hacktoberfest.</p>
<ul>
<li><p>It's okay if you are a beginner, have little experience, or have no experience at all. Hacktoberfest is about embracing open-source and not about proving your skills.</p>
</li>
<li><p>Follow the rules, regulations, and guidelines of the community you are contributing to. In most cases, you can easily find them in community servers or landing pages. Don't hesitate to ping community managers if you don't find them.</p>
</li>
<li><p>Open-source is not just limited to Hacktoberfest. You can contribute to open-source projects, use them in day-to-day life, support maintainers, and do many more things to celebrate open-source in the other 11 months as well.</p>
</li>
</ul>
<p>Last and the most important,</p>
<blockquote>
<p><strong>Hacktoberfest is about embracing open-source, not about rewards you get.</strong></p>
</blockquote>
<h2 id="heading-what-next">What next?</h2>
<p>We hope you have an idea of several ways you can contribute to the ReactPlay. If you still have any doubts, need any clarification, or want any help, leave a DM on Twitter (X) or ask in our community.</p>
<p>Stay connected with the community by...</p>
<h4 id="heading-joining-our-communityhttpsdiscordggvrtxwup8am"><a target="_blank" href="https://discord.gg/vrTxWUP8Am">Joining our community</a></h4>
<h4 id="heading-following-on-twitter-xhttpstwittercomreactplayio"><a target="_blank" href="https://twitter.com/ReactPlayIO">Following on Twitter (X)</a></h4>
<h4 id="heading-subscribing-to-the-newsletterhttpsreactplaysubstackcom"><a target="_blank" href="https://reactplay.substack.com/">Subscribing to the newsletter</a></h4>
]]></content:encoded></item><item><title><![CDATA[Announcing Hack-R-Play 2.0 by ReactPlay]]></title><description><![CDATA[Yes! You read it right! We are back with a hackathon! 🤩
We also know you are as excited as we are, so let's get straight to the point...
Announcing Hack-R-Play 2.0 🚀
Hack-R-Play 2.0 is an online, open-source, React.js hackathon organized by the Rea...]]></description><link>https://blog.reactplay.io/announcing-hack-r-play-2</link><guid isPermaLink="true">https://blog.reactplay.io/announcing-hack-r-play-2</guid><category><![CDATA[hackathon]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[React]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Kaushal Joshi]]></dc:creator><pubDate>Thu, 20 Jul 2023 14:56:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1689864918092/2c3451a1-81a1-4d6d-aaf1-8394fc0e620e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Yes! You read it right! We are back with a hackathon! 🤩</p>
<p>We also know you are as excited as we are, so let's get straight to the point...</p>
<h2 id="heading-announcing-hack-r-play-20">Announcing Hack-R-Play 2.0 🚀</h2>
<p>Hack-R-Play 2.0 is an online, open-source, React.js hackathon organized by the ReactPlay community between the 28th of July and the 11th of August.</p>
<p>Whether you are a seasoned hacker or just getting started, we welcome you both. It doesn't matter how many projects you have built or how many hackathons you have participated in. You can join if you want to become part of something exciting and showcase your ideas.</p>
<p>You can either be a lone wolf and participate alone or partner up with someone. <strong>We allow a maximum of two participants in the team</strong>. If you don't have a partner but want someone on your team, please check our community to see if anybody is interested.</p>
<h3 id="heading-register-now-at-hustlesreactplayiohttpshustlesreactplayio">Register now at <a target="_blank" href="https://hustles.reactplay.io/">hustles.reactplay.io</a></h3>
<p>Registrations are open now! Here's how you can register your idea:</p>
<ol>
<li><p>Go to <a target="_blank" href="https://hustles.reactplay.io/">https://hustles.reactplay.io/</a></p>
</li>
<li><p>Authenticate with your GitHub account</p>
</li>
<li><p>Enter your idea and explain it in brief</p>
</li>
<li><p>If you are partnering up with someone, mention their name or GitHub username. If you are participating alone, keep this blank.</p>
</li>
<li><p>Submit your idea by clicking <code>Register now</code>.</p>
</li>
</ol>
<h2 id="heading-hackathon-timeline">Hackathon timeline ⌚</h2>
<p>Here are the important dates you should not miss:</p>
<ul>
<li><p><strong>Registration and Ideation</strong>: 21st to 27th July</p>
</li>
<li><p><strong>Hacking</strong>: 28th July to 11th August</p>
</li>
<li><p><strong>Demo Day</strong>: 13th August</p>
</li>
<li><p><strong>Results</strong>: 15th August</p>
</li>
</ul>
<p>If the schedule changes for any reason, we will inform you on Twitter and Discord. So make sure you are part of both!</p>
<h2 id="heading-what-to-build">What to build 👩‍💻</h2>
<p>We are not limiting your imagination and creativity in this hackathon. You can build anything that you want, literally anything!</p>
<p>Whether you are someone who works with the web or develops apps for mobiles, or someone who is creating CLI tools or building CLI applications. It doesn't matter. You can build anything. <strong>There is no restriction on what library, framework, or programming language you are using. The project should be yours.</strong></p>
<p><strong>The project should be open-source</strong>. Meaning you need to make its codebase public so anyone can read it. You need to share a GitHub or GitLab link while submitting your project.</p>
<h2 id="heading-side-activities">Side activities ✨</h2>
<p>Hackathon is not just about building projects; it's also about meeting new folks, learning new things, and having fun. We will have several activities along with hackathons.</p>
<ol>
<li><p><strong>Sessions by experts and mentors</strong>: You can learn from industry-leading working professionals and grow further in your career. We will also conduct mentoring sessions where you can clear doubts or clarify further directions regarding the hackathon.</p>
</li>
<li><p><strong>Quizzes and challenges</strong>: We will also conduct various quizzes and challenges throughout the hackathon. This will not only create a friendly competitive environment within the community but also give you a chance to test your skill set.</p>
</li>
<li><p><strong>Giveaways</strong>: Who doesn't love goodies and swags? We will have giveaways multiple times during the hackathon.</p>
</li>
<li><p><strong>Checkpoints</strong>: We know it's difficult to manage your college, work, home, and hackathons altogether. Hence we will have regular check-ins to keep you motivated and on track.</p>
</li>
</ol>
<p>Sound exciting enough? Join our community now to participate in these activities. We will have more activities in the future that you don't want to miss.</p>
<h2 id="heading-judging-criteria">Judging criteria 🥋</h2>
<p>The hackathon is open to everyone with any experience. Hence we are focusing less on the actual product and more on the implementation and demo. Whether you have built a to-do app or your next Facebook, you will be judged like others. Similarly, even if your final product is not built, you can still submit a demo and pitch your project.</p>
<p>Here are the four judging criteria we will consider while selecting projects:</p>
<ol>
<li><p><strong>Idea</strong>: Building an innovative or creative project is a big plus. We don't expect a unique idea, but you must add unique flavor to your project.</p>
</li>
<li><p><strong>UI/UX</strong>: The project should be user-friendly. It must have a visually appealing design and work on devices of different screen sizes.</p>
</li>
<li><p><strong>Using Bugfender SDK/Library:</strong> If the platform you are building on is supported by Bigfender, you must use it in your project. <a target="_blank" href="https://bugfender.com/platforms/">Check available platforms</a>.</p>
</li>
<li><p><strong>Demo</strong>: How you pitch your project on Demo day also plays an important role. Make sure your presentation, demo URLs, and project are working fine.</p>
</li>
<li><p><strong>Content</strong>: Finally, the content you will create based on your project will also be considered while judging your project.</p>
</li>
</ol>
<h2 id="heading-prizes-and-rewards">Prizes and rewards 🏆</h2>
<p>We will select three projects that stand out from the rest. The winners will get exciting cash prizes 💰</p>
<ol>
<li><p><strong>🥇 First winner: $500 USD</strong></p>
</li>
<li><p>🥈 <strong>Second winner: $300 USD</strong></p>
</li>
<li><p>🥉 <strong>Third winner: $200 USD</strong></p>
</li>
</ol>
<p>Also, two noteworthy projects who could not make it into the top three yet are mentionable will be rewarded with <strong>$100 USD each!</strong></p>
<p>Everyone else who participated but could not get shortlisted will receive badges and certificates for participation.</p>
<p>Please note that if you participated as a group, the prize money will be divided equally. Similarly, badges and certificates will be given to individual members.</p>
<h2 id="heading-sponsors">Sponsors 🤗</h2>
<p>We are thankful to our sponsor <strong>Bugfender</strong> for sponsoring this hackathon.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1689857975818/8ee30492-8046-4a7d-a213-ba1b2c67c5b6.png" alt class="image--center mx-auto" /></p>
<p>Bugfender is a log storage service for developers. It collects everything happening in the application, even if it doesn't crash, in order to reproduce and resolve bugs more effectively and provide better customer support. It is built of native Android and iOS, hybrid mobile platforms, as well as for the web.</p>
<p><img src="https://bugfender.com/wp-content/themes/bugfender-wordpress-theme/assets/images/images/as_home_hero.png" alt /></p>
<blockquote>
<p><a target="_blank" href="https://dashboard.bugfender.com/">You can get started with Bugfender from here</a></p>
</blockquote>
<h3 id="heading-become-a-sponsor">Become a sponsor</h3>
<p>If you want to sponsor Hack-R-Play 2.0 or any ReactPlay activity we conduct in the future, we are always open to collaborations!</p>
<blockquote>
<p><a target="_blank" href="https://forms.gle/19KTxhzp4aiTJ4kMA">If you want to sponsor ReactPlay events, please fill out this form</a></p>
</blockquote>
<p>Reach out to us at <a target="_blank" href="mailto:contact@reactplay.io">contact@reactplay.io</a> or send a DM on <a target="_blank" href="https://twitter.com/reactplayio">Twitter</a> if you have any queries</p>
<h3 id="heading-fast-answer-and-questions">Fast Answer and Questions 🔍</h3>
<p>Here are answers to the most common questions participants have:</p>
<h3 id="heading-i-am-just-getting-started-can-i-participate">I am just getting started, can I participate?</h3>
<p>Absolutely yes! We encourage you to participate in this hackathon, especially if you are just getting started with software development. You will surely learn a lot about developing, deploying, and showcasing your project ideas in a competitive way.</p>
<h3 id="heading-i-dont-have-a-project-idea-can-i-participate">I don't have a project idea, can I participate?</h3>
<p>We appreciate your efforts! However, we don't expect a unique project idea or complex problem statement for the hackathon. Pick anything that you are interested in, which lies in your domain, and start building it. Feel free to take help from the internet, ChatGPT, and GitHub to find new ideas.</p>
<p>Don't steal code, though.</p>
<h3 id="heading-is-using-bugfender-necessary">Is using bugfender necessary?</h3>
<p>Yes. If the platform you are working on (web, Android, iOS, etc) is supported by bugfender, you must use it in your project. Bugfender has provided a list of all platforms it currently supports.</p>
<blockquote>
<p><a target="_blank" href="https://bugfender.com/platforms/">Platforms supported by bugfender</a></p>
</blockquote>
<h2 id="heading-closing-notes">Closing notes 🌈</h2>
<p>Are you ready to unleash your coding skills and compete for amazing prizes?</p>
<p>ReactPlay is back with its most anticipated event of the year: <strong>Hack-R-Play 2.0</strong>. Whether you're a seasoned hacker or new to hackathons, this is the perfect opportunity to showcase your talent and learn something new.</p>
<h3 id="heading-register-now-at-hustlesreactplayiohttpshustlesreactplayio-1">Register now at <a target="_blank" href="https://hustles.reactplay.io/">hustles.reactplay.io</a></h3>
<p>Don't miss out on this incredible opportunity to be a part of the Hack-R-Play 2.0 hackathon! Expand your network, learn from experts, and compete for amazing prizes. Register now and get ready to code your way to success.</p>
]]></content:encoded></item><item><title><![CDATA[Maximize Next.js Performance: The Hidden Power of Lazy Loading and Code Splitting]]></title><description><![CDATA[Imagine a web application that loads instantly, with components and resources loading only when needed. A user experience so seamless it feels like magic. Is it possible to achieve such lightning-fast performance without sacrificing functionality? Th...]]></description><link>https://blog.reactplay.io/maximize-nextjs-performance-the-hidden-power-of-lazy-loading-and-code-splitting</link><guid isPermaLink="true">https://blog.reactplay.io/maximize-nextjs-performance-the-hidden-power-of-lazy-loading-and-code-splitting</guid><category><![CDATA[Next.js]]></category><category><![CDATA[lazy loading]]></category><category><![CDATA[code splitting]]></category><category><![CDATA[React]]></category><dc:creator><![CDATA[Shivam Katare]]></dc:creator><pubDate>Thu, 22 Jun 2023 12:13:05 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1687072079143/4e556e38-c1eb-4cd0-bc5d-c3bf173f07f0.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Imagine a web application that loads instantly, with components and resources loading only when needed. A user experience so seamless it feels like magic. Is it possible to achieve such lightning-fast performance without sacrificing functionality? The answer lies in the dynamic duo of <strong>lazy loading</strong> and <strong>code splitting</strong>.</p>
<p><img src="https://assets.vercel.com/image/upload/contentful/image/e5382hct74si/62IUTUtqk3r5xPaGV4WVU0/ef9b7a8baf8b7a7d1a8c9690ea4eddbf/fetching-og.png" alt="Less code, better UX: Fetching data faster with the Next.js 13 App Router –  Vercel" /></p>
<p>We will explore how to implement these powerful techniques in Next.js, a popular framework for building React applications. Get ready to uncover the secrets of lazy loading and code splitting as we delve into their concepts, understand their benefits, and learn how to apply them in our Next.js projects.</p>
<p>Let's get started 🚀</p>
<h2 id="heading-what-is-lazy-loading">What is Lazy Loading?</h2>
<p><img src="https://cdn-images-1.medium.com/fit/t/1600/480/1*btEjjGu76-cHqBA0Re-aDw.gif" alt="Simplifying Lazy Loading in Next.js | by Kithma Marindagoda | Better  Programming" /></p>
<p>Lazy loading is a technique that defers the loading of non-critical or less frequently used components or assets until they are needed. By lazy loading these resources, we can reduce the initial bundle size and improve the initial load time of our application.</p>
<h2 id="heading-what-is-code-splitting">What is Code Splitting?</h2>
<p><img src="https://www.iamtk.co/web-performance-code-splitting-strategies-and-react-applications/1.code-splitting-basics.png" alt="Web performance, code splitting strategies, and a React case study" /></p>
<p>Code splitting is the process of breaking down our application's JavaScript bundle into smaller, more manageable chunks. Instead of loading the entire JavaScript bundle, code splitting allows us to load only the necessary parts of our application when required, reducing the initial load time.</p>
<h2 id="heading-implementing-lazy-loading-and-code-splitting-in-nextjs">Implementing Lazy Loading and Code Splitting in Next.js</h2>
<p>Next.js provides built-in support for lazy loading and code splitting, making it easy to optimize our applications. Let's explore the steps involved:</p>
<h3 id="heading-installing-dependencies">Installing Dependencies</h3>
<p>First, make sure you have Next.js installed in your project. If not, you can install it by running the following command:</p>
<pre><code class="lang-bash">npm install next
</code></pre>
<h3 id="heading-lazy-loading-components">Lazy Loading Components</h3>
<p>Lazy loading components in Next.js is a powerful technique that allows us to load components only when needed. To achieve this, we can use the dynamic import syntax provided by Next.js. Let's break it down with a more relatable example:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> dynamic <span class="hljs-keyword">from</span> <span class="hljs-string">'next/dynamic'</span>;

<span class="hljs-comment">// Lazy load the ImageGallery component</span>
<span class="hljs-keyword">const</span> ImageGallery = dynamic(<span class="hljs-function">() =&gt;</span> <span class="hljs-keyword">import</span>(<span class="hljs-string">'../components/ImageGallery'</span>));

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">HomePage</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Welcome to My Website<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">ImageGallery</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
}

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> HomePage;
</code></pre>
<p>In the above code snippet, we import the <code>dynamic</code> function from Next.js. This function enables us to lazily load the <code>ImageGallery</code> component, which is stored in the <code>../components/ImageGallery</code> file. The dynamic import statement ensures that the component is loaded only w rendered on the page.</p>
<h3 id="heading-advanced-usage-loading-indicator">Advanced Usage: Loading Indicator</h3>
<p>When implementing lazy loading, it's a best practice to provide a loading indicator or fallback content to enhance the user experience. Next.js simplifies this process by offering a <code>loading</code> property. Let's take a look at an example:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> ImageGallery = dynamic(<span class="hljs-function">() =&gt;</span> <span class="hljs-keyword">import</span>(<span class="hljs-string">'../components/ImageGallery'</span>), {
  <span class="hljs-attr">loading</span>: <span class="hljs-function">() =&gt;</span> <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Loading...<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span></span>,
});
</code></pre>
<p>Here we pass a loading function to the dynamic import statement. This function will be executed while the <code>ImageGallery</code> component is being loaded. Within the loading function, we can render a loading indicator or any other content we want to display during the loading process. In this case, we render a simple paragraph that says "<strong>Loading...</strong>" until the component is fully loaded.</p>
<p>By incorporating lazy loading with a loading indicator, we can ensure a smoother user experience by letting users know that content is being loaded in the background. This prevents them from encountering long loading times without any visual feedback.</p>
<p><img src="https://nextjs.org/docs/dark/server-rendering-with-streaming.png" alt="Routing: Loading UI and Streaming | Next.js" /></p>
<p>Lazy loading components and adding loading indicators are valuable techniques that can significantly improve the performance and user experience of our Next.js applications. By loading components only when necessary and providing visual feedback during the loading process, we can create snappy and responsive websites that keep users engaged.</p>
<h3 id="heading-code-splitting-routes">Code Splitting Routes</h3>
<p>Next.js empowers us to split our routes, allowing more control over our application's bundle size. We can achieve this by leveraging the <code>next/dynamic</code> import syntax in conjunction with the <code>Link</code> component from Next.js. Let's explore a simplified example:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> dynamic <span class="hljs-keyword">from</span> <span class="hljs-string">'next/dynamic'</span>;
<span class="hljs-keyword">import</span> Link <span class="hljs-keyword">from</span> <span class="hljs-string">'next/link'</span>;

<span class="hljs-comment">// Lazy load the About page component</span>
<span class="hljs-keyword">const</span> About = dynamic(<span class="hljs-function">() =&gt;</span> <span class="hljs-keyword">import</span>(<span class="hljs-string">'../pages/about'</span>));

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">HomePage</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Welcome to My Next.js App<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>

      <span class="hljs-tag">&lt;<span class="hljs-name">Link</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"/about"</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">a</span>&gt;</span>About<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">Link</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
}

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> HomePage;
</code></pre>
<p>In the above code snippet, we use the <code>dynamic</code> function to load the page component lazily. By wrapping the <code>import('../pages/about')</code> statement inside the <code>dynamic</code> function, we ensure that the component is loaded only when the user navigates to the About page.</p>
<h3 id="heading-advanced-usage-preloading">Advanced Usage: Preloading</h3>
<p>To further optimize the user experience, Next.js preload the code for a specific route. This reduces the loading time when the user navigates to that page. Let's take a look at an example:</p>
<pre><code class="lang-javascript">&lt;Link href=<span class="hljs-string">"/about"</span> prefetch&gt;
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">a</span>&gt;</span>About<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span></span>
&lt;/Link&gt;
</code></pre>
<p>In this example, we add the <code>prefetch</code> attribute to the <code>Link</code> component. By doing so, Next.js will preload the code for the linked page in the background. This means that when the user eventually clicks on the "About" link, the code for the About page will already be loaded, resulting in reduced waiting time and a faster transition to the target page.</p>
<p>By leveraging code splitting and preloading, we can significantly enhance the performance and user experience of our Next.js applications. The ability to lazily load components and routes, combined with the option to prefetch code for specific routes, ensures that our application loads only the necessary code when needed, resulting in faster page transitions and improved overall performance.</p>
<p><img src="https://miro.medium.com/v2/resize:fit:1400/1*Sz9D5CqIG0-CfADFPC6xeA.png" alt="Build it better: Next.js Code Splitting | by Brandon Lange | Medium" /></p>
<p>With Next.js, implementing code splitting and preloading becomes an effortless task, allowing us to optimize our bundle size and initial load time without compromising functionality. Embrace these powerful techniques and witness the transformative impact they can have on your Next.js projects.</p>
<h2 id="heading-benefits-of-using-lazy-loading-and-code-splitting">Benefits of using lazy loading and code splitting</h2>
<ol>
<li><p><strong>Improved Initial Load Time</strong></p>
<ul>
<li><p>Reduces the time it takes for the application to load initially.</p>
</li>
<li><p>Enhances the user experience by displaying content faster.</p>
</li>
</ul>
</li>
<li><p><strong>Faster Page Transitions</strong></p>
<ul>
<li><p>Loads only the necessary code for each page or route.</p>
</li>
<li><p>Enables faster transitions between pages, improving user navigation.</p>
</li>
</ul>
</li>
<li><p><strong>Reduced Bundle Size</strong></p>
<ul>
<li><p>Breaks down the application's JavaScript bundle into smaller chunks.</p>
</li>
<li><p>Loads only the required code, reducing the overall bundle size.</p>
</li>
</ul>
</li>
<li><p><strong>Improved Performance</strong></p>
<ul>
<li><p>Enhances application performance by optimizing load times.</p>
</li>
<li><p>Provides quicker interactions and smoother navigation.</p>
</li>
</ul>
</li>
<li><p><strong>Enhanced Scalability</strong></p>
<ul>
<li><p>Enables selective loading of code as the application grows.</p>
</li>
<li><p>Maintains performance and responsiveness as complexity increases.</p>
</li>
</ul>
</li>
<li><p><strong>Better Resource Management</strong></p>
<ul>
<li><p>Efficiently utilizes system resources by loading components and assets when needed.</p>
</li>
<li><p>Avoids unnecessary loading of unused resources.</p>
</li>
</ul>
</li>
<li><p><strong>Improved SEO</strong></p>
</li>
</ol>
<p>It benefits search engine optimization by allowing critical content to be crawled and indexed quickly.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Lazy loading and code splitting are powerful techniques for optimizing bundle size and improving the initial load time of our Next.js applications. By deferring the loading of non-critical components, displaying loading indicators, and manually code-splitting routes, we can significantly enhance the performance of our applications.</p>
<p><img src="https://cdn.sanity.io/images/ay6gmb6r/production/ff1c8719d8edd546d19e58fdd783d05e68ed73e0-2240x1260.png?w=795&amp;fm=webp&amp;fit=max&amp;auto=format" alt="10 Ways to Improve Your Next.JS App Performance" /></p>
<p>Next.js makes it simple to implement lazy loading and code splitting, allowing us to accomplish these optimizations. By using the dynamic import syntax for inert loading components and the <code>Link</code> component for code splitting routes, we can leverage Next.js's built-in capabilities for optimizing bundle size and initial load time.</p>
<p>So go ahead, implement lazy loading and code splitting in your Next.js projects, and witness the significant improvements in bundle size and initial load time. Your users will thank you for it!</p>
<p>Follow <a target="_blank" href="https://blog.reactplay.io/">ReactPlay Blogs</a> for more content, and join me on my <a target="_blank" href="https://linkfree.io/Shivam-Katare">socials</a>.</p>
<p><em>For more information and advanced usage of lazy loading and code splitting in Next.js, refer to the official documentation</em> <a target="_blank" href="https://nextjs.org/docs/advanced-features/dynamic-import"><em>here</em></a><em>.</em></p>
<blockquote>
<p><strong><em>Note</em></strong>: The code examples provided are simplified for explanatory purposes. An actual implementation may require additional configurations depending on your specific project setup.</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Demystifying Web Development]]></title><description><![CDATA[Introduction.
Web Development is the process of creating and maintaining websites. Web Development is an ever-evolving field that is continuously pushing the boundaries of what is possible on the Internet. In this blog, we will dive into the world of...]]></description><link>https://blog.reactplay.io/demystifying-web-development</link><guid isPermaLink="true">https://blog.reactplay.io/demystifying-web-development</guid><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><category><![CDATA[web]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Abhishek Holani]]></dc:creator><pubDate>Thu, 22 Jun 2023 12:12:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1687245821250/451a3f0c-376c-4c22-9315-befef9cf46b5.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction.</h2>
<p>Web Development is the process of creating and maintaining websites. Web Development is an ever-evolving field that is continuously pushing the boundaries of what is possible on the Internet. In this blog, we will dive into the world of web development, technologies, and other related topics.</p>
<p>Any website has two layers, the frontend (User Interface) and the backend (Data management). Hence, you can become a Frontend Web-Developer that deals with the presentation of data on browsers or you can become a Backend developer that deals with the data behind the scenes or you can become a Full-Stack Web developer that works on both ends.</p>
<p>Let's understand each of these roles and what technologies you need in your arsenal to assume any of these roles.</p>
<h2 id="heading-frontend-developer">Frontend Developer.</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1687248925583/8714b573-775a-43e9-9a7b-d463a2d69944.png" alt class="image--center mx-auto" /></p>
<p>Frontend Developer is the one that deals with the User Interface (UI) of the website. User Interface is the part of the website that users deal with. It is the responsibility of the front-end developer to make this interface as user-friendly as possible.</p>
<blockquote>
<p>"Good frontend development is not just about writing code; it's about understanding users, designing intuitive interfaces, and creating memorable experiences." - Unknown</p>
</blockquote>
<h3 id="heading-the-three-pillars-of-frontend-development">The Three Pillars of Frontend Development.</h3>
<p>To become a front-end developer, a developer needs to know three fundamentals, HTML, CSS, and Javascript. These are the three pillars for creating an attractive, responsive, and user-friendly interface. We as users, interact with a website via browsers. Now let us understand what each of these three is used for. We will take the example of a building to understand it.</p>
<ul>
<li><p>HTML(Hyper Text Markup Language) is used to create the structure of the website and add elements like Images, buttons, text, etc. Like a building has doors, windows similarly HTML creates the structure of the web page.</p>
</li>
<li><p>CSS (Cascading Style Sheet) is used to make the website attractive. Just like in a building you add paint, lights etc to make a building attractive, CSS adds color, font sizes and many other useful styling properties to make your website eye-pleasing.</p>
</li>
<li><p>Javascript is used to give functionality to various elements in your website. Just like a building has switches, electricity, and plumbing to interact with various building functionalities, Javascript adds life to your website. Apart from adding life to the front end, Javascript is also responsible to connect your frontend with the backend.</p>
</li>
</ul>
<p>Having a strong understanding of these 3 fundamentals is important because, at the root level, Browser only understands HTML, CSS, and Javascript.</p>
<p>Once you have a strong understanding of the fundamentals, it is time to learn some high level frameworks and libraries that make your development experience smooth and easy. Here are some of the famous frameworks and libraries you can learn that provide a great development, are widely used in industry and are in high demand.</p>
<h3 id="heading-javascript">Javascript</h3>
<ul>
<li><p><a target="_blank" href="https://react.dev/">React</a></p>
</li>
<li><p><a target="_blank" href="https://angular.io/">Angular</a></p>
</li>
<li><p><a target="_blank" href="https://vuejs.org/">VueJS</a></p>
</li>
<li><p><a target="_blank" href="https://nextjs.org/">NextJS</a></p>
</li>
</ul>
<h3 id="heading-css">CSS</h3>
<ul>
<li><p>SASS</p>
</li>
<li><p>TailwindCSS</p>
</li>
<li><p>Bootstrap</p>
</li>
</ul>
<p>Once you are confident with developing websites there few things you should learn to deliver higher quality.</p>
<ul>
<li><p>SEO (Search Engine Optimization)</p>
</li>
<li><p>Responsive Design Websites</p>
</li>
<li><p>User Experience (UX)</p>
</li>
<li><p>Website Optimisation.</p>
</li>
</ul>
<p>With these skills in your arsenal, you can become a high-quality frontend developer and deliver user-friendly websites.</p>
<h2 id="heading-backend-developer">Backend Developer.</h2>
<p>A Backend Developer works behind the scenes. They are responsible for handling server-side logic and interacting with Databases or external services. It is the duty of the backend developer to handle data processing and send it to the frontend so that it can be presented beautifully. Unlike frontend, backend can be developed using a wide variety of languages as per the developer wish. Here are few frameworks that can help you develop a scalable backend.</p>
<ul>
<li><p><a target="_blank" href="https://flask.palletsprojects.com/en/2.3.x/">Flask</a> and <a target="_blank" href="https://www.djangoproject.com/">Django</a>, for Python.</p>
</li>
<li><p><a target="_blank" href="https://nodejs.dev/en/learn/introduction-to-nodejs/">NodeJS</a> and <a target="_blank" href="https://expressjs.com/">ExpressJS</a>, for Javascript</p>
</li>
<li><p><a target="_blank" href="https://spring.io/projects/spring-boot">Springboot</a>, for Java</p>
</li>
</ul>
<p>Apart from implementing a backend, that deals for user request, backend developer also works with Database to store and manipulate the data. Hence it is also important to learn database to be able to deal with real time information.</p>
<ul>
<li><p><a target="_blank" href="https://www.mysql.com/">MySQL</a></p>
</li>
<li><p><a target="_blank" href="https://www.mongodb.com/docs/atlas/">MongoDB</a></p>
</li>
<li><p><a target="_blank" href="https://www.postgresql.org/">PostgreSQL</a></p>
</li>
</ul>
<p>Once, you can create useful backend services, it is time to optimise it for your growing users. It is worth learning about few things:</p>
<ul>
<li><p>Different architectures</p>
</li>
<li><p>Containerization</p>
</li>
<li><p>Security</p>
</li>
<li><p>Caching</p>
</li>
</ul>
<p>It is duty of frontend developer to make the website attractive, but backend developer behind the scenes, works to make the website smooth and as fast as possible.</p>
<h2 id="heading-full-stack-developer">Full Stack Developer</h2>
<p>A Full-stack developer is part of entire web site development life cycle process, right from design to the deployment of the website, a full stack developer can be involved in the part of the lifecycle. As full stack developer can work anywhere, they must know technologies used in different phases:</p>
<ul>
<li><p>Technologies for Frontend Development</p>
</li>
<li><p>Technologies for Backend Development</p>
</li>
<li><p>Brainstorm for UI design face to provide optimal UX</p>
</li>
<li><p>Able to design System Architecture</p>
</li>
<li><p>Also become a bridge between frontend and backend team.</p>
</li>
</ul>
<h2 id="heading-version-control-tools">Version Control Tools</h2>
<p>It is also important for developers to be familiar with version control tools like Git, Github, Gitlab, Bitbucket. These tools help you to collaborate with other developers, maintain your code history and also merge codes.</p>
<h2 id="heading-conclusion">Conclusion:</h2>
<p>Everything mentioned above are just starting points into web development. The best way to keep improving your skills is keeping building, building projects, taking part in community activities, contributing to open source, helping others fix bugs and so on.</p>
<ul>
<li><p>The more responsive designs you build, the more you will understand what design works on which device.</p>
</li>
<li><p>The more APIs you create the more insight you will get on how to segregate different endpoints.</p>
</li>
<li><p>The more data you handle, the better you get at processing data.</p>
</li>
</ul>
<p>If you find this article useful to begin your web development journey, leave a like and comment below.</p>
<p>Also you can connect and follow me on.</p>
<ul>
<li><p><a target="_blank" href="https://twitter.com/AbhishekHolani6">Twitter</a></p>
</li>
<li><p><a target="_blank" href="https://www.linkedin.com/in/abhishek-holani-65551819b/">Linkedin</a></p>
</li>
</ul>
<h3 id="heading-thankyou">Thankyou!</h3>
]]></content:encoded></item><item><title><![CDATA[How to Escape Tutorial Hell as a Beginner Developer]]></title><description><![CDATA[My web development journey began with an online course. When I finished it, I began another course because certain concepts of the previous one were unclear to me. Then I watched a slew of YouTube videos about web development, projects, careers, jobs...]]></description><link>https://blog.reactplay.io/how-to-escape-tutorial-hell-as-a-beginner-developer</link><guid isPermaLink="true">https://blog.reactplay.io/how-to-escape-tutorial-hell-as-a-beginner-developer</guid><category><![CDATA[ reactnexusplay]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[DevLife]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Kaushal Joshi]]></dc:creator><pubDate>Tue, 20 Jun 2023 18:05:10 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1687283660151/83745710-4c92-4de8-9341-7f35ec74e67e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>My web development journey began with an online course. When I finished it, I began another course because certain concepts of the previous one were unclear to me. Then I watched a slew of YouTube videos about web development, projects, careers, jobs, and other topics.</p>
<p>Finally, I decided to create a project on my own. And to my surprise, I was miserably stuck. It felt like I have learned nothing until now. Hence I completed another course and built some projects following YouTube videos. But when I went back to building something independently, I was back to square one.</p>
<p>I was stuck in <strong>tutorial hell</strong>. I was merely copying one tutorial after another rather than applying what I had learned. I was blindly following instructions and copying code when I should have understood what I was doing.</p>
<p>In this blog, let's talk about tutorial hell and how to escape it.</p>
<h2 id="heading-what-is-tutorial-hell">What is tutorial hell?</h2>
<p>Consider someone who wishes to learn to cook. They watch a lot of cooking videos and are familiar with how to cook a specific meal. They read books about how to cook better and make food taste better. They even buy all of the cooking ingredients and utensils. However, they never start cooking.</p>
<p>This is exactly what tutorial hell is. Tutorial hell is a state of being stuck in a cycle of following tutorials without being able to build anything on your own. Tutorial hells are part of a developer's life when they are getting started. Many newbie developers fall into tutorial hell and realize it too late.</p>
<p>This is what a cycle of tutorial hell looks like:</p>
<ol>
<li><p>You follow a tutorial. It could be a crash course, BootCamp, YouTube video series, or blog.</p>
</li>
<li><p>When you are done, you start building something on your own.</p>
</li>
<li><p>While doing so, you get stuck quite a lot of time and feel like you know nothing.</p>
</li>
<li><p>You go to step one!</p>
</li>
</ol>
<h2 id="heading-how-does-one-fall-into-tutorial-hell">How does one fall into tutorial hell?</h2>
<p>Tutorial hell is not a path newbie developers take willingly. It's a pit they fall accidentally into because they are not focused on the correct path. We will talk about the <em>correct path</em> soon.</p>
<p>Here are some of the reasons why you are likely to fall into tutorial hell while starting software development.</p>
<h3 id="heading-tutorials-are-already-perfect">Tutorials are already perfect</h3>
<p>When we follow a tutorial, the creator has already made several attempts and failed several times before finishing it. However, when presented, it is perfect, with no bugs, errors, or anything whatsoever. Therefore we tend to think that if we follow the tutorial, we will also be able to code without any mistakes.</p>
<p>Blindly following tutorials become a comfort zone. It looks perfect, gives a feeling of achievement, and a delusion that we are becoming a better developer. But in reality, we are just reiterating something that's already built.</p>
<p>But learning something without making mistakes is not learning at all. You succeed when you make mistakes, learn from them, and try again. This brings me to my second point, you are afraid of making mistakes.</p>
<h3 id="heading-you-are-afraid-of-making-mistakes">You are afraid of making mistakes</h3>
<p>When we are on our own, we make more mistakes. Mistakes make us feel dumb, and our anxieties pile up. Hence we tend to choose to follow someone else and build something. We are often terrified of making mistakes because we think if we are making mistakes, we don't know anything.</p>
<blockquote>
<p>We learn something only when we make mistakes</p>
</blockquote>
<p>It's quite the opposite. When we make mistakes and analyze what went wrong, we get an opportunity to fix them. And while fixing those mistakes, we learn something new. And the next time, we won't make the same mistake again.</p>
<h3 id="heading-you-are-delusional-about-your-skills">You are delusional about your skills</h3>
<p>This was my case. We think we would understand the concept just by watching a video or reading a blog. We assume we will grasp everything by consuming the content on the go. But it is not the case.</p>
<blockquote>
<p>Practise makes the man perfect.</p>
</blockquote>
<p>The only thing to get better at something is doing it repetitively, not looking at others doing it.</p>
<h2 id="heading-how-to-get-out-of-tutorial-hell">How to get out of tutorial hell?</h2>
<p>The sooner you escape the tutorial hell, the sooner will your true journey start. Escaping tutorial hell is no rocket science. Let's discuss methods to get out of tutorial hell in this section.</p>
<h3 id="heading-learn-the-fundamentals">Learn the fundamentals</h3>
<p>You should not entirely stop following tutorials. But you should know when to stop. When you are just getting started, familiarizing yourself with a language, library, or framework, tutorials are a good headstart.</p>
<p>When you get started, make yourself comfortable with fundamental concepts. Focus on understanding the concept first and then practically implement it later.</p>
<p>When you are just getting started, there are several resources that you can follow:</p>
<ul>
<li><p>Official documentation</p>
</li>
<li><p>Crash course</p>
</li>
<li><p>YouTube playlist</p>
</li>
<li><p>Blog series</p>
</li>
</ul>
<p>When you find the resource you are comfortable with, follow it and learn the nuances of it. One thing to note here is that tutorials must cover all the important aspects of the concept.</p>
<h3 id="heading-build-guided-projects">Build guided projects</h3>
<p>When you are comfortable with fundamentals, start building projects.</p>
<p>At first, follow a tutorial just like you used to. But this time, rather than blindly following it, use the following method:</p>
<ol>
<li><p>Split the tutorial into multiple sections based on its working, scope, or your understanding.</p>
</li>
<li><p>Then watch individual sections separately. Rewatch it until you understand it completely.</p>
</li>
<li><p>Take a pen and paper and write what you understood. You can write about the procedure, pseudo code, algorithms, steps, etc. You can also make diagrams, flow charts, and illustrations to better understand it. If you fail at this step, go to step 2 again and do it again.</p>
</li>
<li><p>Now it's time to code. Don't watch the tutorial. Only refer to the document you wrote in the previous step. Build a project just by your written understanding of your project.</p>
</li>
<li><p>If you get stuck, follow the last three steps again. At any cost, don't watch the tutorial and directly jump to coding.</p>
</li>
<li><p>When you are done with the section, review it. If it's satisfactory, then move to the next section. Otherwise, go to step 2.</p>
</li>
</ol>
<p>This method takes longer than regular tutorials, but it definitely helps. You build the project by yourself and learn a lot in the process.</p>
<p>Don't build too many guided projects, though. Otherwise, you will fall into another type of tutorial hell. When you have built a couple of guided projects, start building your own projects.</p>
<h2 id="heading-build-more-projects">Build more projects</h2>
<p>If you have a project idea, then start building it. Otherwise, research beginner to intermediate project ideas on the internet. Make sure that project covers essential aspects of the language, library, or tool you are learning.</p>
<p>Don't limit yourself at this stage. Explore your skillset, play around with new technologies and concepts, and learn along the way. You will get stuck sometimes, but try solving those problems by yourself or ask for help on the Internet. Having like-minded folks, peers and mentors help in this case.</p>
<p>There is no limit to how many projects you must make. But make sure you build meaningful projects to add to your portfolio or resume.</p>
<h3 id="heading-contribute-to-open-source-projects">Contribute to open-source projects</h3>
<p>Contributing to opensource is a multivitamin tablet that significantly improves your overall health.</p>
<p>Join an open-source community dedicated to your domain and contribute to its projects. It would be difficult initially, but eventually, you will grasp everything. The community is always there to help you. Open-source contributions help you upskill by letting you solve real-world problems.</p>
<p>If you are into web development, feel free to join ReactPlay!</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://discord.com/channels/982239924227031070/985625463093346324">https://discord.com/channels/982239924227031070/985625463093346324</a></div>
<p> </p>
<h3 id="heading-create-content-on-your-learnings">Create content on your learnings</h3>
<p>You fully understand something when you teach it to someone else.</p>
<p>Taking your learnings one step further, if you really want to challenge yourself, creating content based on your learnings is the best way is the best way to know if you have understood something or not.</p>
<p>I started my blog with a similar intention. I wanted to keep a record of everything I learned. You can do this too. There are several ways you can create content on the internet:</p>
<ul>
<li><p>Write blogs</p>
</li>
<li><p>Create videos or short-form content</p>
</li>
<li><p>Write threads on Twitter</p>
</li>
<li><p>Give talks, presentations</p>
</li>
</ul>
<p>When you do this, you can be assured that you are truly learning something and growing in your career. And, of course, you must never stop learning. Whatever we discussed today will be helpful for a very long time.</p>
<h2 id="heading-closing-notes">Closing notes</h2>
<p>Don't feel demotivated if you are currently in a tutorial hell. You are not the first one falling into it and definitely won't be the last.</p>
<blockquote>
<p>Awareness is the first step toward change!</p>
</blockquote>
<p>Now that you are aware of your current state, start taking action. Don't rush things and take one step at a time. Here is a call to action so you won't feel overwhelmed:</p>
<ol>
<li><p>Make a note of what tools, technologies, programming languages, libraries, or frameworks you are learning. Pick a maximum of three co-related concepts together. For example: React.js, Tailwind CSS, and TypeScript.</p>
</li>
<li><p>Read its documentation and projects if they are mentioned in the tutorial. Otherwise, take notes of what you are learning.</p>
</li>
<li><p>Follow a YouTube or a blog series around the most important topic and build a few projects while you do so. Remember the method we discussed to build guided projects.</p>
</li>
<li><p>At the same time, join an open-source community around your domain. Meet like-minded peers and experienced developers in the community.</p>
</li>
<li><p>Contribute to open-source projects. There is plenty of material available on how to do so.</p>
</li>
<li><p>Start building your own projects as well. Try to solve problems on your own. Ask for help in communities and online forums if you are unable to solve it.</p>
</li>
<li><p>If you are comfortable, create and share content based on your learning. What you create is totally based on your comfort zone, experience, and interests.</p>
</li>
</ol>
<p>And always remember, never stop learning!</p>
<h2 id="heading-lets-connect">Let's connect!</h2>
<p>Did you fall into a tutorial hell as well? Are you currently into one? Or were you able to escape it? I would love to know your story. Let's connect so we can have a further discussion about this.</p>
<ul>
<li><p><a target="_blank" href="https://twitter.com/clumsy_coder">Twitter</a></p>
</li>
<li><p><a target="_blank" href="https://www.showwcase.com/clumsycoder">Showwcase</a></p>
</li>
<li><p><a target="_blank" href="https://peerlist.io/kaushal">Peerlist</a></p>
</li>
</ul>
<p>I write about web development, open-source, technical writing, and my general experiences with communities and software development. Make sure you read my other blogs as well!</p>
<ul>
<li><p><a target="_blank" href="https://kaushaljoshi.dev/blogs">Blog</a></p>
</li>
<li><p><a target="_blank" href="https://blog.kaushaljoshi.dev/">Subscribe to my blog</a></p>
</li>
</ul>
<p>I would love to hear back from you.</p>
<p>Until next time, keep learning! 🐱‍🏍</p>
]]></content:encoded></item><item><title><![CDATA[Unleashing the Power of Aliases: Simplify Your JavaScript Imports!]]></title><description><![CDATA[🎉 Hello, fellow tech enthusiasts! Are you tired of dealing with long, confusing import statements in your JavaScript projects?

Do you often get lost in a maze of folders, trying to find the right file to import? Well, worry no more because I have a...]]></description><link>https://blog.reactplay.io/unleashing-the-power-of-aliases-simplify-your-javascript-imports</link><guid isPermaLink="true">https://blog.reactplay.io/unleashing-the-power-of-aliases-simplify-your-javascript-imports</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[General Programming]]></category><category><![CDATA[React]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[#codenewbies]]></category><dc:creator><![CDATA[Shivam Katare]]></dc:creator><pubDate>Tue, 16 May 2023 13:06:59 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1684239328816/0b23c156-b52c-4e0d-931d-97365156a051.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>🎉 Hello, fellow tech enthusiasts! Are you tired of dealing with long, confusing import statements in your JavaScript projects?</p>
<p><img src="https://project-assets.showwcase.com/13602/1684047990615-Screenshot%2520(935).png" alt /></p>
<p>Do you often get lost in a maze of folders, trying to find the right file to import? Well, worry no more because I have a solution that will completely change your development experience: <strong>aliases! 🚀✨</strong></p>
<p>In JavaScript development, imports are essential for bringing different modules, components, and utilities together. However, as your project becomes more complex, the length and complexity of your import statements can become overwhelming. All those <code>../../../</code> paths can turn your codebase into a tangled mess, making it harder for you to be productive and enjoy coding.</p>
<p>But fear not! Aliases are here to rescue you from this <code>import</code> chaos! 🦸‍♂️✨ With aliases, you can say goodbye to those long import paths and embrace a simpler and more elegant solution. They act as shortcuts, giving you shorter and more convenient names for your files and folders, turning your import statements into beautiful ones.</p>
<p>In this blog post, we will embark on a quest to explore the wonders of shortening your JS imports with aliases. Together, we will uncover the secrets behind this powerful technique and learn how to use it to our advantage.</p>
<p><img src="https://media2.giphy.com/media/mcPlsaB0VcZ67aIsTz/giphy.gif?cid=ecf05e47lk2k1s9pl2ek47ua2b03yb9fbz2awdlmuhudt29y&amp;ep=v1_gifs_search&amp;rid=giphy.gif&amp;ct=g" alt="Discover Video Game GIF by Naughty Dog" /></p>
<p>Imagine a world where your import statements are clear, concise, and expressive. A world where navigating through your codebase is effortless and collaborating with other developers is seamless. This is the world that aliases unlock for you.</p>
<p>So, join me on this exciting journey as we discover the magic of aliases, empowering you to take your JavaScript development to the next level and embrace a new era of simplicity and efficiency.</p>
<p>Are you ready to transform your import statements from chaos to clarity? Let's dive in! 💻🚀</p>
<h2 id="heading-the-power-of-aliases-a-new-path-to-simplicity">✨ The Power of Aliases: A New Path to Simplicity</h2>
<p>Imagine you're working on a project with multiple nested folders and repeatedly importing modules with those dreaded lengthy paths.</p>
<p><img src="https://res.cloudinary.com/practicaldev/image/fetch/s--v9etKldi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9s4ml9xt9baf40o1kjxd.gif" alt="File nesting in VS Code - DEV Community" /></p>
<p>It's like navigating through a labyrinth! But worry not; aliases are here to rescue you from this chaos. It provides a simpler and more elegant solution for importing modules, making your code cleaner, more readable, and easier to maintain. Let's delve into the magic of aliases and see how they can transform your development workflow!</p>
<h2 id="heading-what-are-aliases-and-how-do-they-work">🔗 What are Aliases, and How Do They Work?</h2>
<p>🎩 In JavaScript development, aliases allow us to give shorter and easier names to files and folders when importing them. By using aliases, we can make the import process simpler, improve how our code looks, and have a better overall experience. Let's take a closer look at how this works! 🔧</p>
<p>Aliases act as shortcuts or alternative names for specific file or folder paths in our project. Instead of using long and complex paths, we can assign aliases to these paths and use them when importing.</p>
<p>For example, imagine we have a React project structured like this:</p>
<p>📂 Project Structure:</p>
<pre><code class="lang-javascript">📁 src
  📁 components
    📁 navbar
      📄 Navbar.js
  📁 utils
    📄 helpers.js
</code></pre>
<p>🔍 Without aliases, importing a module would look like this:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> Navbar <span class="hljs-keyword">from</span><span class="hljs-string">'../../../components/navbar/Navbar'</span>;
<span class="hljs-keyword">import</span>{ someHelperFunction }<span class="hljs-keyword">from</span><span class="hljs-string">'../../../utils/helpers'</span>;
</code></pre>
<p>As your project grows, the number of directories and nested levels increase, making the imports more difficult to read and maintain.</p>
<p>But with aliases, we can achieve cleaner and more concise imports like this:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> Navbar <span class="hljs-keyword">from</span><span class="hljs-string">'@components/navbar/Navbar'</span>;
<span class="hljs-keyword">import</span>{ someHelperFunction }<span class="hljs-keyword">from</span><span class="hljs-string">'@utils/helpers'</span>;
</code></pre>
<p>With the @components and @utils aliases, we don't have to use long and confusing relative paths in our import statements. This means that we <code>import</code> become easier to read and understand.</p>
<p>🎨 Think of your project structure as a big city, with directories as different neighbourhoods and files as buildings within those neighbourhoods.</p>
<p><img src="https://u-static.fotor.com/images/text-to-image/result/PRO-b57046f0b1344050a7475f85fa2412b4.jpg" alt="Imagine your project structure - AI Image Generator - Fotor.jpg" /></p>
<p>Aliases act like clear signs or landmarks that show you the direct way to specific locations. Instead of getting lost in a maze of streets, you can take a shortcut by following these recognizable signs. This saves time and effort and also reduces the chances of getting lost in the city.</p>
<h3 id="heading-setting-up-aliases-in-react-js">Setting Up Aliases in React JS:</h3>
<p>🛠️ Modern JavaScript frameworks, like React, make it easy to use aliases. Let's see how we can set up aliases in a React project.</p>
<p>React projects often use <strong>Create React App (CRA)</strong> to start quickly. CRA provides a simple way to configure aliases.</p>
<p>Step 1: Open your project's <code>jsconfig.json</code> file. If you don't have one, create it in the main directory.</p>
<p>Step 2: In <code>jsconfig.json</code>, find the <code>compilerOptions</code> section and add the following code:</p>
<pre><code class="lang-json">{
  <span class="hljs-attr">"compilerOptions"</span>: {
    <span class="hljs-attr">"baseUrl"</span>: <span class="hljs-string">"src"</span>,
    <span class="hljs-attr">"paths"</span>: {
      <span class="hljs-attr">"@components/*"</span>: [<span class="hljs-string">"components/*"</span>],
      <span class="hljs-attr">"@utils/*"</span>: [<span class="hljs-string">"utils/*"</span>]
    }
  }
}
</code></pre>
<p>Here's what this configuration does:</p>
<ul>
<li><p><code>baseUrl</code>: It sets the base directory for aliases. In our case, it's set to <code>"src"</code>, so aliases will be relative to the <code>src</code> directory.</p>
</li>
<li><p><code>paths</code>: This section defines our aliases and their corresponding paths. In this example, we have <code>@components</code> and <code>@utils</code> aliases that point to their respective directories.</p>
</li>
</ul>
<p>By setting aliases, we tell React how to resolve our alias imports during compilation. This allows us to use aliases throughout our project and enjoy their benefits.</p>
<p>🔧 For projects using custom Webpack configurations, you can achieve the same result by adding alias configurations to your <code>webpack.config.js</code> file. Here's an example:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> path = <span class="hljs-built_in">require</span>(<span class="hljs-string">'path'</span>);

<span class="hljs-built_in">module</span>.exports = {
  <span class="hljs-comment">// Other webpack configuration options...</span>
  <span class="hljs-attr">resolve</span>: {
    <span class="hljs-attr">alias</span>: {
      <span class="hljs-string">'@components'</span>: path.resolve(__dirname, <span class="hljs-string">'src/components'</span>),
      <span class="hljs-string">'@utils'</span>: path.resolve(__dirname, <span class="hljs-string">'src/utils'</span>)
    }
  }
};
</code></pre>
<p>In this example, we use the <code>resolve</code> property in the Webpack configuration to define our aliases. The <code>alias</code> object maps our aliases, such as <code>@components</code> and <code>@utils</code>, to their respective absolute paths.</p>
<p>By using either the CRA <code>jsconfig.json</code> or custom Webpack configurations, you can effortlessly set up aliases in your React project and enjoy cleaner, more readable import statements.</p>
<h3 id="heading-visualizing-the-benefits">Visualizing the Benefits:</h3>
<p>⚡️ Let's take a closer look at the benefits of using aliases in React JS development:</p>
<p><img src="https://www.bigscal.com/wp-content/uploads/2022/01/A-Guide-To-Achieve-Clean-Code-And-Best-Coding-Practices-495x400.png" alt="A Guide To Achieve Clean Code And Best Coding Practices | Bigscal" class="image--center mx-auto" /></p>
<p><strong>Enhanced Readability</strong>: Imagine working on a big React project with lots of files and folders. Without aliases, your import statements would be long and confusing, filled with complex paths. It becomes hard to understand which files depend on each other. But with aliases, things get much simpler. You can use shorter and more intuitive names to import modules, making it easier for you and your teammates.</p>
<p><img src="https://www.wyzant.com/blog/wp-content/uploads/2021/03/Why-You-Should-Learn-At-Least-A-Little-Coding-For-Your-Career-1024x576.png.webp" alt="Why You Should Learn At Least A Little Coding For Your Career - Wyzant Blog" /></p>
<p><strong>Improved Maintainability:</strong> As your React project evolves, you might need to move components or utilities to different folders. Without aliases, you'd have to manually update import statements throughout your codebase, which can be time-consuming and error-prone. However, when you use it, it's a breeze. All your imports will automatically point to the new locations if you change the alias-to-path mapping in your configuration file. This saves you time and reduces the chances of introducing mistakes during refactoring.</p>
<p><img src="https://ckeditor.com/blog/is-coding-for-everyone/feature.png" alt="Is coding for everyone? Can you become a programmer? Check this out!" /></p>
<p><strong>Team Collaboration:</strong> Collaboration is key to successful software development. Aliases play a significant role in making collaboration smoother. They provide a common language for import statements, making it easier for team members to navigate the codebase, regardless of their familiarity with specific folder structures. When everyone on the team adopts aliases, it creates a shared understanding and reduces confusion, enabling faster collaboration and development.</p>
<p>Aliases improve the clarity, simplicity, and efficiency of your applications. These advantages will improve your coding experience, boost cooperation, and speed up the process. So why not embrace aliases and take your React projects to the next level? Let's unlock its potential together! 💻🚀</p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>🌟 Congratulations on discovering the power of aliases in your React JS development! With aliases, you can make importing code easier, improve how readable your code is, and boost your productivity. No more struggling with complicated paths that can lead to errors! Embrace aliases and enjoy a smoother development experience.</p>
<p>🚀 So, don't hesitate to use aliases in your React or JavaScript projects. Aliases will improve your development process whether you're working on a tiny application or a large corporate system. Happy coding, and may your React projects thrive with newfound efficiency and clarity! 💻🎉</p>
<p>I'm always excited to hear your thoughts, experiences, and any questions you may have. Feel free to share them in the comments below. Let's continue this conversation and inspire each other to create amazing JavScript applications. Until next time, keep exploring the endless possibilities of technology! 🔥</p>
<p>Follow <a target="_blank" href="https://blog.reactplay.io/">ReactPlay Blogs</a> for more exciting content, and join me on my <a target="_blank" href="https://linkfree.io/Shivam-Katare">social media channels</a>. Thank you for reading!</p>
]]></content:encoded></item><item><title><![CDATA[ReactPlay Announces Open Mic for Developer Community]]></title><description><![CDATA[🏮 ANNOUNCEMENT 🏮
We are excited to announce the Open Mic initiative from ReactPlay. Public Speaking is exciting. Unfortunately, most developers stay back from it for fear of being judged. ReactPlay's Open Mic is one of the rarest platforms for you ...]]></description><link>https://blog.reactplay.io/reactplay-announces-open-mic-for-developer-community</link><guid isPermaLink="true">https://blog.reactplay.io/reactplay-announces-open-mic-for-developer-community</guid><category><![CDATA[General Programming]]></category><category><![CDATA[Public Speaking]]></category><category><![CDATA[General Advice]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[#codenewbies]]></category><dc:creator><![CDATA[ReactPlay Blog]]></dc:creator><pubDate>Wed, 10 May 2023 12:29:02 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1683721472343/dc992230-2724-4f31-8a55-2eb3298eeb5d.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>🏮 ANNOUNCEMENT 🏮</p>
<p>We are excited to announce the Open Mic initiative from ReactPlay. Public Speaking is exciting. Unfortunately, most developers stay back from it for fear of being judged. ReactPlay's Open Mic is one of the rarest platforms for you to start your Public Speaking Journey. Get on board, developers!</p>
<h2 id="heading-what-is-open-mic">🔵 What is "Open Mic"? 🎙</h2>
<p>"Open Mic" is an initiative to inspire and motivate developers to Public Speaking. At the same time, open up a channel to share lots about tech, open source, and software development. It will be a bi-weekly virtual meet-up for developers to attend, learn, and share for free!</p>
<h2 id="heading-when-are-we-starting">🔵 When Are We Starting? 🗓</h2>
<p>Our first "Open Mic" will take place on 12th May Friday, between 8 pm - 9 pm (IST). We have three exciting talks in these areas:</p>
<ul>
<li><p>Clean Code</p>
</li>
<li><p>What's new in Next.js</p>
</li>
<li><p>UX Stay tuned to { ReactPlay } for the update and link to join.</p>
</li>
</ul>
<h2 id="heading-i-am-interested-in-speaking-how">🔵 I am Interested in speaking; how? 🤔</h2>
<p>You are welcome! It doesn't matter if you are a beginner or a PRO. Just fill out this form, and we'll reach out to you. Public Speaking is fantastic, and we encourage you to try it. No one will be Judged, promise!</p>
<blockquote>
<p>Link: <a target="_blank" href="https://lnkd.in/gyP97hF5">https://lnkd.in/gyP97hF5</a></p>
</blockquote>
<p>I hope you support us in this initiative. The ReactPlay Open Source community is beyond just ReactJS. Join us to contribute, collaborate, and connect.</p>
<h2 id="heading-the-first-episode">🔵 The First Episode</h2>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://www.youtube.com/watch?v=d36eeq0w1ug">https://www.youtube.com/watch?v=d36eeq0w1ug</a></div>
<p> </p>
<h2 id="heading-join-us">🔵 JOIN US</h2>
<p>Join the ReactPlay Discord Server! ReactPlay is an Open Source Community that helps you improve with Web Dev, JavaScript, React, Next.js, and Full Stack!</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://lnkd.in/geieHqHB">https://lnkd.in/geieHqHB</a></div>
]]></content:encoded></item><item><title><![CDATA[Revamp your Git workflow with the magic of Git Rebasing.]]></title><description><![CDATA[Have you ever found yourself lost in a sea of branching and merging while working on a project in Git? Do you dread the thought of trying to merge changes from a long-lived branch into your own? Fear not, for there is a solution to streamline your Gi...]]></description><link>https://blog.reactplay.io/revamp-your-git-workflow-with-the-magic-of-git-rebasing</link><guid isPermaLink="true">https://blog.reactplay.io/revamp-your-git-workflow-with-the-magic-of-git-rebasing</guid><category><![CDATA[Git]]></category><category><![CDATA[Git Workflow ]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[General Programming]]></category><category><![CDATA[Open Source]]></category><dc:creator><![CDATA[Shivam Katare]]></dc:creator><pubDate>Mon, 01 May 2023 06:34:43 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1682772411396/cf6b9ce3-3bdb-4534-b248-d04342979d2b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Have you ever found yourself lost in a sea of branching and merging while working on a project in Git? Do you dread the thought of trying to merge changes from a long-lived branch into your own? Fear not, for there is a solution to streamline your Git workflow: <strong>Git Rebasing</strong>.</p>
<p><img src="https://miro.medium.com/v2/resize:fit:868/1*g48HJkKNsZwNlWEM6Z82ig.jpeg" alt="Understanding Git merge &amp; Git rebase | by Amit Prajapati | MindOrks | Medium" /></p>
<p>This powerful tool can help you keep your commit history clean and organized and make conflict resolution a breeze. In this article, we'll dive into the <strong>magic of Git Rebasing</strong> and show you how to revamp your workflow for a smoother, more efficient programming experience.</p>
<h3 id="heading-introduction">Introduction</h3>
<p>Git is a distributed version control system that allows developers to track changes to their code over time. Git is widely used in the software development industry and has become an essential tool for programmers.</p>
<p><img src="https://miro.medium.com/v2/resize:fit:603/1*75GIyh005_Wl9vRQF3tgTQ.png" alt="Small Commits for Fun and Profit, part 2: git commit --amend and git rebase  --interactive | by Alexander Quine | Bleacher Report Engineering" class="image--center mx-auto" /></p>
<p>Git rebasing is a powerful feature that allows developers to streamline their workflow by modifying the commit history of a branch. Rebasing is an alternative to merging, which can clutter the commit history and make it difficult to track changes over time.</p>
<h3 id="heading-what-is-git-rebasing">What is Git Rebasing?</h3>
<p>Git rebasing is a process that allows you to reapply changes from one branch to another. It works by taking the changes made in one branch and applying them to another branch as if they were always there.</p>
<p>Let's visualize this example scenario with a diagram. In the diagram below, we have a simplified representation of the commit history for our project:</p>
<pre><code class="lang-typescript">             o --- o --- o --- o --- o (master)
            /
o --- o --- o --- o --- o --- o --- o (feature-A)
</code></pre>
<p>We can see that the <code>master</code> branch has five commits, while the <code>feature-A</code> branch has seven commits. Now, let's say that another team member has made changes to the <code>"master"</code> branch and we need to incorporate those changes into our <code>feature-A</code> branch.</p>
<p>One way to do this is to use Git merging:</p>
<pre><code class="lang-typescript">             o --- o --- o --- o --- o --- o (feature-A)
            /                             /
o --- o --- o --- o --- o --- o --- o --- o (master)
</code></pre>
<p>As we can see, Git creates a new commit that combines the changes from both branches. However, this creates a <strong>non-linear commit</strong> history, which can make it difficult to understand the evolution of our codebase.</p>
<p>Alternatively, we can use <strong>Git rebasing</strong> to integrate the changes directly into the <code>feature-A</code> branch:</p>
<pre><code class="lang-typescript">             o --- o --- o --- o --- o --- o --- <span class="hljs-string">'o'</span> --- <span class="hljs-string">'o'</span> --- <span class="hljs-string">'o'</span> (feature-A)
            /
o --- o --- o --- o --- o --- o --- o --- o (master)
</code></pre>
<p>In this case, Git applies the changes from the <code>master</code> branch directly onto the <code>feature-A</code> branch, creating a cleaner and more linear commit history. We can see that the <code>feature-A</code> branch now has three new commits (<code>o'</code>, <code>o'</code>, and <code>o'</code>) that incorporate the changes from the <code>master</code> branch.</p>
<p>This example shows how Git rebasing can help us to maintain a cleaner and more understandable commit history.</p>
<h3 id="heading-when-to-use-git-rebasing">When to Use Git Rebasing?</h3>
<p>Git rebasing is beneficial in a variety of situations, including working with long-lived branches and working with a team. When working on large projects with multiple contributors, rebasing can help keep the commit history clean and easy to understand.</p>
<p>One of the benefits of using <strong>Git rebasing</strong> is that it makes it easier to resolve conflicts. When you rebase a branch, Git tries to apply the changes from the rebased branch to the target branch in a linear fashion. If there are conflicts, Git will pause the rebasing process and allow you to resolve the conflicts manually.</p>
<p>This can be more straightforward than merging, which can create merge conflicts that are difficult to resolve.</p>
<ul>
<li>To better understand the benefits of Git rebasing, let's take an example.</li>
</ul>
<p>Suppose you and your team are working on a project and have been working on separate branches. You have been working on a <code>feature branch</code> for a while, and during this time, the <code>main branch</code> has been updated several times. Now, you want to merge your changes from the feature branch to the main branch.</p>
<p>Here's where Git rebasing can come in handy. Instead of merging your changes, you can rebase your <code>feature branch</code> onto the <code>main branch</code>. This will create a linear commit history, which is easier to understand and follow.</p>
<p>The following diagram illustrates the difference between merging and rebasing:</p>
<pre><code class="lang-bash">Merging: 

                A---B---C---D---E  main
               /                 \
    F---G---H---I---J---K---L---M  feature

Rebasing:

                A---B---C---D---E---I<span class="hljs-string">'---J'</span>---K<span class="hljs-string">'---L'</span>---M<span class="hljs-string">'  main
                                             /
                              F---G---H---------                 feature</span>
</code></pre>
<p>As you can see, the rebased commit history is much cleaner and easier to follow. It also eliminates any unnecessary merge commits, making it easier to track down bugs or issues.</p>
<p>Moreover, it can be beneficial when working on a long-lived branch, such as a release branch. When you rebase your <code>feature branch</code> onto the <code>release branch</code>, you can ensure that your changes are up-to-date with the latest changes in the <code>release branch</code>. This can help prevent any conflicts or issues down the road.</p>
<p>In addition, it is worth noting that Git rebasing should be used with caution, especially if you are working on a public repository or with other collaborators. Rewriting the commit history can create confusion and make it difficult for others to understand what changes were made and why. As a best practice, always communicate with your team before rebasing and ensure that everyone is on the same page.</p>
<h3 id="heading-how-to-use-git-rebasing">How to Use Git Rebasing?</h3>
<p>Let's dive into the process of performing Git rebasing step-by-step.</p>
<p><strong>Step 1</strong>: Update the Local Repository</p>
<p>Make sure your local repository is up to date with the remote repository by running the following command:</p>
<pre><code class="lang-bash">git fetch
git pull
</code></pre>
<p>This will ensure that you have the latest changes from the remote repository.</p>
<p><strong>Step 2:</strong> Checkout Target Branch</p>
<p>Checkout the branch that you want to rebase onto by running the following command:</p>
<pre><code class="lang-bash">git checkout target_branch
</code></pre>
<p>This will switch your working branch to <code>target_branch</code>, which will be the new base for your changes.</p>
<p><strong>Step 3</strong>: Initiate Git Rebase</p>
<p>Now, run the following command to initiate the Git rebase process, where <code>source_branch</code> is the branch that contains the changes that you want to apply to the <code>target_branch</code>:</p>
<pre><code class="lang-bash">git rebase source_branch
</code></pre>
<p>This command will apply the changes made in the <code>source_branch</code> onto the <code>target_branch</code>.</p>
<p>For example, let's say that you have the following commit history:</p>
<pre><code class="lang-bash">      Original                        Updated
         |                                |
         A                                A
        /                                / \
       B    &lt;- Branch A                B   C
      /                                /
     C    &lt;- Branch B                D
</code></pre>
<p>Here, <code>Branch A</code> is the <code>target_branch</code> and <code>Branch B</code> is the <code>source_branch</code>. The <code>git rebase source_branch</code> command will apply the changes made in <code>Branch B</code> (commit <code>C</code>) onto <code>Branch A</code>, resulting in a new commit <code>D</code>. The commit history will now look like this:</p>
<pre><code class="lang-bash">         A<span class="hljs-string">'                               A'</span>
        /                                / \
       B                                B   C
      /                                /
     C                                D
</code></pre>
<p><strong>Step 4:</strong> Resolve Conflicts</p>
<p>During the rebasing process, conflicts may arise, which can be resolved manually. You can identify the conflicts by running:</p>
<pre><code class="lang-bash">git status
</code></pre>
<p>This will show the conflicting files. Resolve any conflicts that arise during the rebasing process by opening the conflicting file in your code editor and editing the file to resolve the conflicts. After resolving the conflicts, mark them as resolved by running:</p>
<pre><code class="lang-bash">git add conflicting_file

// conflicting_file is a filename
</code></pre>
<p><strong>Step 5:</strong> Continue Rebase</p>
<p>Once the conflicts are resolved, continue the rebasing process by running the following command:</p>
<pre><code class="lang-bash">git rebase --<span class="hljs-built_in">continue</span>
</code></pre>
<p>This will apply the remaining changes and create a new commit for each change.</p>
<p><strong>Step 6:</strong> Push Changes</p>
<p>Finally, push your changes to the remote repository by running:</p>
<pre><code class="lang-bash">git push
</code></pre>
<p>This will update the remote repository with the new commit history.</p>
<p>By following these steps, you can successfully rebase a branch, apply changes from one branch to another, and maintain your commit history clean and clear.</p>
<h3 id="heading-common-mistakes-and-how-to-avoid-them">Common Mistakes and How to Avoid Them</h3>
<p>Mistakes are common when it comes to Git rebasing, but they can be easily avoided with a bit of caution and communication. Here are some common mistakes to watch out for:</p>
<p><img src="https://cdn.gloveworx.com/images/9_26_mistakes.2e16d0ba.fill-1600x900.jpg" alt="Mistakes Can Make You Better: Learn From Them | Gloveworx" /></p>
<p>🚫👥🙅‍♂️ <strong>Not understanding the potential consequences of the process</strong>: Rewriting the commit history can make it difficult to understand how the project evolved. To prevent misunderstanding, utilize rebasing only in suitable instances and communicate your actions to your team.</p>
<p><strong>Example</strong>: Let's say you are working on a project with a team and decide to rebase your branch onto the master branch without communicating with your team.</p>
<p><img src="https://img.freepik.com/free-vector/business-team-discussing-ideas-startup_74855-4380.jpg" alt="Project Team Images - Free Download on Freepik" class="image--center mx-auto" /></p>
<p>However, unbeknownst to you, one of your team members had made changes to the master branch while you were working on your branch. When you rebase, their changes will be overwritten, potentially causing conflicts and errors down the line. To avoid this, communicate with your team before rebasing to ensure that everyone is on the same page.</p>
<p><strong>🤝🔎👀 Not resolving conflicts properly:</strong> Carefully reviewing and resolving conflicts is crucial to ensure the integrity of the codebase. If conflicts are not resolved correctly, it can lead to errors in the code and potentially cause bigger issues down the line.</p>
<p><strong>Diagram:</strong> When rebasing, it's possible to encounter conflicts where changes made in one branch conflict with changes made in another branch. In these cases, it's important to carefully review the conflicting changes and resolve them properly.</p>
<pre><code class="lang-typescript">       Original                        Updated
         |                                |
         A                                A
        /                                / \
       B    &lt;- Branch A                B   C
      /                                /
     C    &lt;- Branch B                D
</code></pre>
<p>In the example above, both Branch A and Branch B have changes to the same file. When Branch A is rebased onto Branch B, there is a conflict as both branches have changes to the same file. It's important to carefully review the changes and resolve the conflict properly to ensure that the final result is correct.</p>
<p><strong>🤝💬👥 Not communicating with your team:</strong> Beginners may not realize that rebasing can potentially overwrite changes made by other team members. To avoid overwriting important changes, it's a good idea to only rebase branches that are under your control or communicate with the relevant team members before rebasing.</p>
<p><strong>Diagram</strong>: When multiple team members are working on the same project, it's important to communicate before rebasing to avoid overwriting each other's changes.</p>
<pre><code class="lang-typescript">          Master Branch
                  |
                  A    &lt;- Team member <span class="hljs-number">1</span><span class="hljs-string">'s branch
                 / \
         B     C   D  &lt;- Team member 2'</span>s branch
        /       \
  E   F         G    &lt;- Your branch
   \ /           |
    H            H<span class="hljs-string">'   &lt;- Result after rebasing your branch onto the master branch</span>
</code></pre>
<p>In the example above, multiple team members are working on different branches. When you rebase your branch onto the master branch, you may overwrite changes made by other team members if you're not careful. To avoid this, communicate with your team members before rebasing to ensure that everyone is aware of the changes being made.</p>
<p>To avoid these mistakes and ensure the success of Git rebasing, remember to:</p>
<p>🚫👥🙅‍♂️ avoid confusion</p>
<p>🤝🔎👀 review and resolve conflicts properly</p>
<p>🤝💬👥 communicate with your team</p>
<p>Using Git rebasing can be a powerful tool to streamline your workflow, but it's necessary to use it properly and communicate with your team to avoid potential issues.</p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>In conclusion, Git rebasing can be a powerful tool for keeping your commit history clean and making collaboration on projects smoother. However, it's necessary to use it wisely and communicate with your team to avoid common mistakes like overwriting changes or creating confusion in the commit history.</p>
<p>I hope this blog has given you a better understanding of Git rebasing and how to use it effectively. If you enjoyed reading this, be sure to follow <a target="_blank" href="https://reactplay.hashnode.dev/">ReactPlay blogs</a> for more informative content. Don't forget to give it a thumbs up and share it with your friends. You can also follow me on my <a target="_blank" href="https://linkfree.eddiehub.io/Shivam-Katare">socials</a> for more updates. Happy coding!</p>
]]></content:encoded></item><item><title><![CDATA[Content Creation: A Gateway to Opportunities[by Shashank]]]></title><description><![CDATA[As a content creator in the world of developers, you play a crucial role in providing access to high-quality documentation, video tutorials, social media content, blogs, and articles that help your audience learn and stay up to date with the latest t...]]></description><link>https://blog.reactplay.io/content-creation-a-gateway-to-opportunitiesby-shashank</link><guid isPermaLink="true">https://blog.reactplay.io/content-creation-a-gateway-to-opportunitiesby-shashank</guid><category><![CDATA[#react-play-anniversary-23]]></category><category><![CDATA[ReactPlay]]></category><category><![CDATA[General Advice]]></category><dc:creator><![CDATA[Shashank Dwivedi]]></dc:creator><pubDate>Mon, 17 Apr 2023 15:52:12 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1681620504126/6e20cbb4-9ddc-4ec0-903f-979f28128213.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>As a content creator in the world of developers, you play a crucial role in providing access to high-quality documentation, video tutorials, social media content, blogs, and articles that help your audience learn and stay up to date with the latest trends and techniques in the field. In this article, I'll be sharing insights from a Twitter space discussion that took place on April 13, 2023, to celebrate the first anniversary of ReactPlay. During the discussion, experts and successful content creators shared their strategies for creating engaging and effective content and discussed the benefits of content creation. This article is primarily based on the blog and article-type content creation. I will also be sharing some resources suggested by experts to help you learn and upgrade your technical blogging skills. By the end of this article, you'll have a better understanding of what it takes to create quality content that resonates with your audience and helps you stand out in a crowded market.</p>
<h3 id="heading-benefits-of-article-writing-opportunities-and-advantages">Benefits of Article Writing: Opportunities and Advantages</h3>
<p>Article writing provides a multitude of opportunities and advantages for content creators. By consistently publishing high-quality articles, you can establish yourself as an expert in your field and build a strong professional network. You may also gain exposure to potential clients and employers, expanding your reach and increasing your chances of receiving referrals. Additionally, article writing can lead to remote job opportunities or even the chance to launch your own book based on your published work. It's important to remember that in today's digital age, <strong>either you can be well known, or knowing well can make you famous</strong>. By regularly producing valuable content, you can establish yourself as a thought leader in your industry and open doors to new opportunities.</p>
<h3 id="heading-how-to-choose-topics-tips-for-selecting-engaging-and-relevant-content">How to Choose Topics: Tips for Selecting Engaging and Relevant Content</h3>
<p>Choosing the right topic is crucial to creating engaging and relevant content that resonates with your audience. There are several strategies for selecting topics that can help you streamline the process and ensure that you're creating content that your readers will find valuable.</p>
<p>One approach is to write about what you're learning. As you learn new skills and techniques, you can document your progress and share your insights with others. This not only helps you solidify your own understanding, but it also provides a valuable resource for others who are just starting out.</p>
<p>Another approach is to write about topics that aren't widely available on the internet, or that have less quality content. By doing this, you can establish yourself as an expert in a particular niche and attract readers who are hungry for more information.</p>
<p>If you don't have the time to do research, don't worry. Just write about what you've learned so far or share your experiences from hackathons or other events. You'd be surprised at how many people are interested in hearing about your journey and what you've learned along the way.</p>
<p>Lastly, it's important to know your audience and choose topics accordingly. If you're writing for a technical audience, for example, you'll want to choose topics that are relevant to their interests and level of expertise. On the other hand, if you're writing for a more general audience, you'll want to choose topics that are more accessible and easier to understand. By knowing your audience, you can create content that resonates with them and keeps them coming back for more.</p>
<p>For those who are engaged in full-time work, there is very little time to research something and write, so write on those topics on which you are working, and keep it close to what you are learning and doing at your work. So, it will become a part of your journey.</p>
<h3 id="heading-consistency-and-quality-importance-of-maintaining-standards">Consistency and Quality: Importance of Maintaining Standards</h3>
<p>Consistency and quality are two important aspects of content creation that should not be overlooked. Consistency in writing helps build a loyal audience and establish your brand. It is important to choose a schedule that works for you and stick to it. Whether it's once a week or twice a month, make sure you are consistent. However, it is equally important to maintain quality while being consistent. Your content should be well-researched, well-written, and informative. Don't compromise on quality just to meet deadlines.</p>
<p>As the saying goes, <strong>"If you tell a lie big enough and keep repeating it, people will eventually come to believe it."</strong> Consistency is powerful, but it should not come at the cost of truthfulness. Your content should be accurate, and you should avoid spreading misinformation.</p>
<p>Quality should always be a top priority. Make sure you know your subject well before you start writing. Spend time researching and verifying your facts. Be mindful of your tone, and write in a beginner to advanced friendly manner so that everyone can understand it. Your readers are investing their time in reading your content, so make sure you provide them with value.</p>
<p>Remember, there is a lot of content out there, but people will only choose yours if it has quality. Quality is what sets you apart from the rest. If you're not satisfied with your content, then it's not of good quality. Don't be afraid to rewrite or make revisions until you're happy with it.</p>
<p>Additionally, content creation doesn't just have to be limited to writing articles or creating videos. You can also share your daily learnings and experiences through Twitter threads or LinkedIn posts. This is a great way to maintain consistency and keep your audience engaged. Just remember to keep the same standards of quality and accuracy in all forms of content creation.</p>
<h3 id="heading-what-to-avoid-bad-practices-to-steer-clear-of">What to Avoid: Bad Practices to Steer Clear Of</h3>
<ul>
<li><p>Avoid clickbait titles that mislead readers and don't match the content of your article. This can create a bad impression and result in readers leaving your page.</p>
</li>
<li><p>Don't get discouraged if your article doesn't receive a lot of views or likes immediately. Building an audience and establishing yourself as a writer takes time and consistent effort.</p>
</li>
<li><p>Avoid writing about topics that are irrelevant or don't make sense. Your content should provide value to your readers and be informative.</p>
</li>
<li><p>Don't compromise on quality by rushing to meet deadlines or sacrificing accuracy for the sake of consistency. Your content should be well-researched, well-written, and informative.</p>
</li>
<li><p>Avoid copying content from other sources or using images without permission. This is not only unethical but can also result in legal consequences.</p>
</li>
<li><p>Don't neglect proofreading and editing. Spelling and grammar errors can create a bad impression and distract readers from your message.</p>
</li>
</ul>
<p>Lastly, remember to stay true to yourself and your writing style. Don't try to imitate others or change your style to fit trends. Your unique voice and perspective are what make your content stand out.</p>
<h3 id="heading-resources-to-learn-blogging">Resources to learn Blogging</h3>
<p>There is a resource shared by ReactPlay in the Twitter space that can aid in learning to blog. I have personally visited this resource and found it to be well-explained, covering all the fundamental tips and tricks for blogging, which can help you kickstart your own blog.</p>
<p>The link to this resource is <a target="_blank" href="http://showwcase.com/series/4755/all-about-technic"><strong>showwcase.com/series/4755/all-about-technic</strong></a><a target="_blank" href="https://www.showwcase.com/series/4755/all-about-technical-blogging"><strong>..</strong></a>.</p>
<h3 id="heading-advice-for-newbies-expert-tips-for-creating-engaging-and-effective-content">Advice for Newbies: Expert Tips for Creating Engaging and Effective Content</h3>
<ul>
<li><p>Understand your purpose in creating content and be selfless in your approach. Use your content for yourself first before sharing it with others.</p>
</li>
<li><p>Don't let imposter syndrome take over you. Believe in yourself and play your own game in this field.</p>
</li>
<li><p>Choose content that interests you and write in your specific style while following the basic rules of content creation.</p>
</li>
<li><p>Remember, it takes time to become famous in this field. Even the experts in the Twitter space took more than a year to gain popularity.</p>
</li>
</ul>
<p>Write about what you're learning, and don't just follow trends. Play the game according to your own rules and create content that you're passionate about.</p>
<h3 id="heading-questions-from-listeners-and-answers-from-experts-insights-from-the-reactplay-twitter-space-discussion">Questions from Listeners and Answers from Experts: Insights from the ReactPlay Twitter Space Discussion</h3>
<p>I have noted and selected some of the questions that were asked during the ReactPlay Twitter Space discussion by listeners. The experts provided insightful answers to these questions, which can be valuable for aspiring bloggers. Here are some of the questions and their answers from the discussion:</p>
<ol>
<li><p><strong>Is it necessary to be an expert on the topic you are writing about?</strong></p>
<p> No, It's not necessary to be an expert on a particular topic to start writing about it. You can share your knowledge, but ensure that the information you share is correct and factual. Prioritize quality content over quantity, and conduct thorough research before publishing any information to prevent sharing incorrect information. Sharing high-quality, accurate content will also help to improve your knowledge of the topic.</p>
</li>
<li><p><strong>It is still worthwhile to write blogs even in the era of ChatGPT?</strong></p>
<p> The answer is yes because AI uses the web to extract data and create content, it doesn't generate answers out of thin air. Writing blogs allows you to share your unique perspective and insights on a topic, which can be valuable to your audience.</p>
</li>
<li><p><strong>How to manage time for writing with your full-time work?</strong></p>
<p> You learn time management with time. As time passes, you gain experience and become more adept at writing articles. To save time, use tools like Grammarly and ChatGPT to correct grammatical errors and other mistakes. When you work consistently on something you get better automatically. Additionally, make plans to write on weekends.</p>
</li>
<li><p><strong>I don't have enough knowledge about my subject to write the article because currently I am in the learning phase.</strong></p>
<p> It's common to feel like you don't have enough knowledge to write about a subject when you're still in the learning phase. However, don't stop learning to create content. If creating content is taking time, don't worry, focus on learning and gaining knowledge about that topic first.</p>
</li>
<li><p><strong>What are the different ways to monetize your content?</strong></p>
<p> First of all, don't hesitate to monetize your content. You are giving your valuable time, so you deserve a return on investment. There are several ways to monetize your content. For example, you can sell your own products or services, add affiliate promotions, offer sponsored content or product reviews, or display ads on your website or social media channels. You can also consider creating premium content or offering exclusive access to your audience for a fee. Whatever method you choose, ensure it aligns with your brand and provides value to your audience.</p>
</li>
</ol>
<h3 id="heading-conclusion">Conclusion</h3>
<p>In conclusion, content creation provides numerous opportunities and advantages for content creators. By producing high-quality articles, creators can establish themselves as experts in their field, build a strong professional network, gain exposure to potential clients and employers, and even open doors to new opportunities. Choosing the right topics is crucial to creating engaging and relevant content that resonates with the audience. Writing about what you're learning, exploring less-available topics, and sharing your experiences can help streamline the process. Consistency and quality are two important aspects that creators must maintain while creating content. Consistency helps to build a loyal audience, and quality is what sets you apart from the rest. Finally, content creators should avoid clickbait titles, and irrelevant or controversial topics, and not get discouraged if their articles don't receive much attention immediately. By following these guidelines, content creators can create effective and engaging content that resonates with their audience and helps them stand out in the crowded market.</p>
<p>Here is the link to the Twitter Space recording: <a target="_blank" href="https://twitter.com/i/spaces/1DXxyvXAONVKM">https://twitter.com/i/spaces/1DXxyvXAONVKM</a></p>
<p>Thanks for reading! I hope you find this blog post useful. If yes, don't forget to like it. You can connect with me on <a target="_blank" href="https://twitter.com/shashankoffice"><strong>Twitter</strong></a> and <a target="_blank" href="https://www.linkedin.com/in/shashankoffice/">Linkedin</a></p>
]]></content:encoded></item><item><title><![CDATA[Mastering TypeScript: A Comprehensive Guide for Getting Started with TypeScript]]></title><description><![CDATA[TypeScript is a strongly typed superset of JavaScript that adds optional static typing, classes, and interfaces to the language. TypeScript can help you catch errors before runtime and provide better editor support for your code. This tutorial is you...]]></description><link>https://blog.reactplay.io/mastering-typescript-a-comprehensive-guide-for-getting-started-with-typescript</link><guid isPermaLink="true">https://blog.reactplay.io/mastering-typescript-a-comprehensive-guide-for-getting-started-with-typescript</guid><category><![CDATA[TypeScript]]></category><category><![CDATA[ReactPlay]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[General Programming]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Shivam Katare]]></dc:creator><pubDate>Mon, 17 Apr 2023 02:29:23 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1681502860304/b6ed699b-575f-4468-b426-ee620ec720ce.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>TypeScript is a strongly typed superset of JavaScript that adds optional static typing, classes, and interfaces to the language. TypeScript can help you catch errors before runtime and provide better editor support for your code. This tutorial is your ultimate guide to mastering the basics of TypeScript and getting started with it like a pro.</p>
<p><img src="https://cdn-images-1.medium.com/max/1600/1*i0qclSPNcjj8cWOPr3wLxg.png" alt="TypeScript — Because I don’t have time for JavaScript" /></p>
<h2 id="heading-setting-up-typescript"><strong>Setting Up TypeScript</strong></h2>
<p>Before we can start writing TypeScript code, we need to set up our development environment. Here are the steps to set up TypeScript:</p>
<h3 id="heading-1-install-typescript">1. Install TypeScript</h3>
<p>The first step is to install TypeScript globally using npm. Open your terminal or command prompt and run the following command:</p>
<pre><code class="lang-typescript">npm install -g typescript
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681213686899/975b2785-73c9-4e16-b084-5509c7b5e55e.jpeg" alt class="image--center mx-auto" /></p>
<p>This will install the latest version of TypeScript on your system. The <code>-g</code> option installs TypeScript globally, so you can use it from any directory.</p>
<h3 id="heading-2-create-a-new-typescript-file">2. Create a new TypeScript file</h3>
<p>Next, create a new file with an <code>.ts</code> extension. This will be our TypeScript source file. You can name the file anything you like, but for this example, we will call it <code>index.ts</code>.</p>
<p>Open your text editor and create a new file called <code>index.ts</code>. Add the following line of code:</p>
<pre><code class="lang-typescript"><span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Hello, TypeScript!'</span>);
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681213750927/565de099-9570-4abc-9dea-7204009d2b6c.png" alt class="image--center mx-auto" /></p>
<p>This is a simple TypeScript program that prints a message to the console.</p>
<h3 id="heading-3-compile-the-typescript-file">3. Compile the TypeScript file</h3>
<p>Now that we have our TypeScript source file, we need to compile it to JavaScript. To do this, we will use the TypeScript compiler <code>tsc</code>.</p>
<p>Open your terminal or command prompt and navigate to the directory where your <code>index.ts</code> file is located. Then, run the following command:</p>
<pre><code class="lang-bash">tsc index.ts
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681213827167/ab143f3d-d66d-4708-b8dc-d60b7ff2c806.png" alt class="image--center mx-auto" /></p>
<p>This will compile the TypeScript file to JavaScript. The output will be a new file called <code>index.js</code> in the same directory as your TypeScript file.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681213958144/3c914dfb-ca10-4e08-b95b-d15bdbacd116.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-4-run-the-javascript-file">4. Run the JavaScript file</h3>
<p>Now that we have our JavaScript file, we can run it (if we want) using Node.js. Open your terminal or command prompt and run the following command:</p>
<pre><code class="lang-javascript">node index.js
</code></pre>
<p>This will run the JavaScript file. You should see the message <strong>"Hello, TypeScript!"</strong> printed on the console.</p>
<p>Congratulations! You have set up TypeScript and compiled your first TypeScript program into JavaScript. You can start writing more complex programs using TypeScript's advanced features such as <code>type annotations</code>, <code>classes</code>, and <code>interfaces</code>.</p>
<h2 id="heading-basic-typescript-concepts"><strong>Basic TypeScript Concepts</strong></h2>
<p>TypeScript is a statically typed language, which means we can define types for variables, functions, and other constructs. Let's start by discussing variables and data types.</p>
<h3 id="heading-variables-and-data-types">Variables and Data Types</h3>
<p>In TypeScript, we can declare variables using the <code>let</code> or <code>const</code> keyword. We can also specify the type of a variable using the <code>:Type</code> syntax. For example, we can declare a variable <code>count</code> of <strong><em>type</em></strong> <code>number</code> like this:</p>
<pre><code class="lang-typescript"><span class="hljs-comment">// Variable with a specific type</span>
<span class="hljs-keyword">let</span> count: <span class="hljs-built_in">number</span> = <span class="hljs-number">5</span>;
</code></pre>
<p>If you don't specify a type, TypeScript will infer it based on the value assigned to the variable:</p>
<pre><code class="lang-typescript"><span class="hljs-comment">// Variable with inferred type</span>
<span class="hljs-keyword">let</span> message = <span class="hljs-string">'Hello, TypeScript!'</span>;
</code></pre>
<p>TypeScript supports the following data types:</p>
<ul>
<li><p><code>number</code> for numeric values</p>
</li>
<li><p><code>string</code> for text values</p>
</li>
<li><p><code>boolean</code> for true/false values</p>
</li>
<li><p><code>any</code> for the value that can be of any type</p>
</li>
</ul>
<h3 id="heading-functions-and-interfaces">Functions and Interfaces</h3>
<p>Functions in TypeScript can have types for their parameters and return values. For example, we can define a function <code>addNumbers</code> that takes two <code>number</code> parameters and returns a <code>number</code>:</p>
<pre><code class="lang-typescript">
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">addNumbers</span>(<span class="hljs-params">a: <span class="hljs-built_in">number</span>, b: <span class="hljs-built_in">number</span></span>): <span class="hljs-title">number</span> </span>{  <span class="hljs-comment">//here `number` is the type of `a` and `b`. It means, we can also assign numbers to them, if we will try to give any other values like string or boolean, then it will going to give us error. </span>
  <span class="hljs-keyword">return</span> a + b;
}
</code></pre>
<p>Interfaces in TypeScript define the shape of an object. For example, we can define an interface <code>Person</code> that has a <code>name</code> property of type <code>string</code> and an <code>age</code> property of type <code>number</code>:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">interface</span> Person {
  name: <span class="hljs-built_in">string</span>;
  age: <span class="hljs-built_in">number</span>;
}
</code></pre>
<p>We can then create an object of the type <code>Person</code> like this:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">let</span> person: Person = {
  name: <span class="hljs-string">'John'</span>,
  age: <span class="hljs-number">30</span>
};
</code></pre>
<h3 id="heading-classes-and-objects">Classes and Objects</h3>
<p>TypeScript also supports classes and objects. We can define a class <code>Greeter</code> that has a <code>greeting</code> property and a <code>greet</code> method:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">class</span> Greeter {
  greeting: <span class="hljs-built_in">string</span>;

  <span class="hljs-keyword">constructor</span>(<span class="hljs-params">message: <span class="hljs-built_in">string</span></span>) {
    <span class="hljs-built_in">this</span>.greeting = message;
  }

  greet() {  <span class="hljs-comment">//this is greet method/function</span>
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Hello, <span class="hljs-subst">${<span class="hljs-built_in">this</span>.greeting}</span>!`</span>);
  }
}
</code></pre>
<p>We can then create an object of the type <code>Greeter</code> and call its <code>greet</code> method:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">let</span> greeter = <span class="hljs-keyword">new</span> Greeter(<span class="hljs-string">'TypeScript'</span>);
greeter.greet(); <span class="hljs-comment">// Hello, TypeScript!</span>
</code></pre>
<h3 id="heading-modules-and-namespaces">Modules and Namespaces</h3>
<p>TypeScript has built-in support for modules and namespaces. Modules allow you to organize your code into reusable, shareable units. For example, we can define a <code>Greeter</code> class in a separate file <code>greeter.ts</code> and then import it into our main file <code>app.ts</code> like this:</p>
<pre><code class="lang-typescript"><span class="hljs-comment">// greeter.ts &lt;- FileName</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> Greeter {
  <span class="hljs-comment">// ...</span>
}

<span class="hljs-comment">// app.ts &lt;- FileName</span>
<span class="hljs-keyword">import</span> { Greeter } <span class="hljs-keyword">from</span> <span class="hljs-string">'./greeter'</span>;

<span class="hljs-keyword">let</span> greeter = <span class="hljs-keyword">new</span> Greeter(<span class="hljs-string">'TypeScript'</span>);
greeter.greet();
</code></pre>
<p>Namespaces allow you to group related code. For example, we can define a namespace <code>MyNamespace</code> that has a <code>message</code> property.</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">namespace</span> MyNamespace {
  <span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> message = <span class="hljs-string">'Hello, TypeScript!'</span>;
}

<span class="hljs-built_in">console</span>.log(MyNamespace.message);
</code></pre>
<h2 id="heading-advanced-typescript-concepts"><strong>Advanced TypeScript Concepts</strong></h2>
<h3 id="heading-generics-and-type-inference">Generics and Type Inference</h3>
<p>Generics are a valuable TypeScript feature that allows you to write reusable code that works with a variety of <code>types</code>. In TypeScript, you can define a function or a class with a <code>generic type</code> parameter, which can be used to represent any type.</p>
<p>For example, consider the following identity function that returns its argument:</p>
<pre><code class="lang-typescript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">identity</span>&lt;<span class="hljs-title">T</span>&gt;(<span class="hljs-params">arg: T</span>): <span class="hljs-title">T</span> </span>{
  <span class="hljs-keyword">return</span> arg;
}

<span class="hljs-keyword">let</span> result = identity&lt;<span class="hljs-built_in">string</span>&gt;(<span class="hljs-string">'Hello, TypeScript!'</span>);
</code></pre>
<p>Here, <code>T</code> is a type parameter that represents any <code>type</code>. The <code>function identity</code> takes an argument of type <code>T</code> and returns a value of the same <code>type</code>. In the example above, we're using the function <code>identity</code> with the type parameter <code>string</code> to return the string "<strong>Hello, TypeScript!</strong>".</p>
<p><strong>Type inference</strong> in TypeScript allows the compiler to infer types depending on the context. For example, if we don't specify the type parameter of the <code>identity</code> function, TypeScript will infer it based on the type of the argument:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">let</span> result = identity(<span class="hljs-string">'Hello, TypeScript!'</span>); <span class="hljs-comment">//if we'll use booleans here, then, TS will think the result is a boolean value.</span>
</code></pre>
<p>Here, TypeScript infers that the type parameter <code>T</code> is <code>string</code> based on the argument "Hello, TypeScript!".</p>
<h3 id="heading-decorators-and-mixins"><strong>Decorators and Mixins</strong></h3>
<ul>
<li><strong>Decorators</strong></li>
</ul>
<p>In simple terms, a <strong>decorator</strong> is a way to add extra functionality to a class, function, property, or method in TypeScript. They are a special kind of declaration that can be attached to a class declaration, method, accessor, property, or parameter. Decorators are similar to annotations in other programming languages and are used to modify the behavior of a class or its members at runtime.</p>
<p>Let's consider an example. Imagine you have a class called <code>Logger</code> that logs information about a class's method calls. With decorators, you can attach this <code>Logger</code> class to any method in your codebase. Here's how it works:</p>
<pre><code class="lang-typescript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">log</span>(<span class="hljs-params">target: <span class="hljs-built_in">any</span>, key: <span class="hljs-built_in">string</span>, descriptor: PropertyDescriptor</span>) </span>{
  <span class="hljs-keyword">const</span> originalMethod = descriptor.value;

  descriptor.value = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">...args: <span class="hljs-built_in">any</span>[]</span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Calling <span class="hljs-subst">${key}</span> with`</span>, args);
    <span class="hljs-keyword">const</span> result = originalMethod.apply(<span class="hljs-built_in">this</span>, args);
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Result:`</span>, result);
    <span class="hljs-keyword">return</span> result;
  };

  <span class="hljs-keyword">return</span> descriptor;
}

<span class="hljs-keyword">class</span> MyClass {
  <span class="hljs-meta">@log</span>
  myMethod(value: <span class="hljs-built_in">number</span>): <span class="hljs-built_in">number</span> {
    <span class="hljs-keyword">return</span> value * <span class="hljs-number">2</span>;
  }
}

<span class="hljs-keyword">const</span> myClass = <span class="hljs-keyword">new</span> MyClass();
myClass.myMethod(<span class="hljs-number">5</span>);
</code></pre>
<p>In this example, we create a <code>Logger</code> class that has a <code>log</code> method that logs a message to the console. We then define a <code>logMethodCall</code> decorator function that takes in three arguments: <code>target</code>, <code>propertyKey</code>, and <code>descriptor</code>. The decorator function then modifies the <code>descriptor</code> object of the <code>foo</code> the method by replacing its value with a new function that logs information about the method call before calling the original function and returning its result.</p>
<p>Now, when we call <a target="_blank" href="http://example.foo"><code>example.foo</code></a><code>()</code>, the decorator function <code>logMethodCall</code> is executed, and it logs information about the method call before calling the original <code>foo</code> function.</p>
<p>Real-world examples of decorators include things like logging, authentication, and validation. For instance, you could create a <code>@authenticated</code> decorator that checks if a user is logged in before allowing them to access a specific method.</p>
<ul>
<li><strong>Mixins</strong></li>
</ul>
<p>A mixin is a way to combine the functionality of multiple classes into a single one. In other words, mixins allow you to create a new class that has all the features of multiple existing classes.</p>
<p>Here's an example:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">class</span> Animal {
  <span class="hljs-keyword">public</span> move(distanceInMeters: <span class="hljs-built_in">number</span>) {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Animal moved <span class="hljs-subst">${distanceInMeters}</span>m.`</span>);
  }
}

<span class="hljs-keyword">class</span> CanSwim {
  <span class="hljs-keyword">public</span> swim(distanceInMeters: <span class="hljs-built_in">number</span>) {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Swimming <span class="hljs-subst">${distanceInMeters}</span>m.`</span>);
  }
}

<span class="hljs-keyword">class</span> CanFly {
  <span class="hljs-keyword">public</span> fly(distanceInMeters: <span class="hljs-built_in">number</span>) {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Flying <span class="hljs-subst">${distanceInMeters}</span>m.`</span>);
  }
}

<span class="hljs-keyword">class</span> Duck <span class="hljs-keyword">implements</span> CanSwim, CanFly {
  swim: <span class="hljs-function">(<span class="hljs-params">distanceInMeters: <span class="hljs-built_in">number</span></span>) =&gt;</span> <span class="hljs-built_in">void</span>;
  fly: <span class="hljs-function">(<span class="hljs-params">distanceInMeters: <span class="hljs-built_in">number</span></span>) =&gt;</span> <span class="hljs-built_in">void</span>;

  <span class="hljs-keyword">constructor</span>(<span class="hljs-params"></span>) {
    <span class="hljs-built_in">this</span>.swim = CanSwim.prototype.swim.bind(<span class="hljs-built_in">this</span>);
    <span class="hljs-built_in">this</span>.fly = CanFly.prototype.fly.bind(<span class="hljs-built_in">this</span>);
  }
}

applyMixins(Duck, [CanSwim, CanFly]);

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">applyMixins</span>(<span class="hljs-params">derivedCtor: <span class="hljs-built_in">any</span>, baseCtors: <span class="hljs-built_in">any</span>[]</span>) </span>{
  baseCtors.forEach(<span class="hljs-function"><span class="hljs-params">baseCtor</span> =&gt;</span> {
    <span class="hljs-built_in">Object</span>.getOwnPropertyNames(baseCtor.prototype).forEach(<span class="hljs-function"><span class="hljs-params">name</span> =&gt;</span> {
      <span class="hljs-built_in">Object</span>.defineProperty(
        derivedCtor.prototype,
        name,
        <span class="hljs-built_in">Object</span>.getOwnPropertyDescriptor(baseCtor.prototype, name)
      );
    });
  });
}

<span class="hljs-keyword">const</span> duck = <span class="hljs-keyword">new</span> Duck();
duck.swim(<span class="hljs-number">10</span>);
duck.fly(<span class="hljs-number">20</span>);
</code></pre>
<p>In this example, we have three classes: <code>Animal</code>, <code>CanSwim</code>, and <code>CanFly</code>. <code>Animal</code> has a <code>move</code> the method that logs information about an animal's movement. <code>CanSwim</code> has a <code>swim</code> the method that logs information about swimming, and <code>CanFly</code> has a <code>fly</code> the method that logs information about flying.</p>
<p>We then define a new class <code>Duck</code> that implements <code>CanSwim</code> and <code>CanFly</code>. We manually bind the <code>swim</code> and <code>fly</code> methods of <code>CanSwim</code> and <code>CanFly</code> to the <code>Duck</code> class's instance.</p>
<p>We then define a <code>applyMixins</code> function that takes a derived constructor and an array of base constructors. This function iterates over the base constructors and copies their properties and methods to the prototype of the derived constructor. This is how we add the functionality of <code>CanSwim</code> and <code>CanFly</code> to the <code>Duck</code> class.</p>
<p>Finally, we create a new <code>Duck</code> instance and call its <code>swim</code> and <code>fly</code> methods to test the implementation of the <code>CanSwim</code> and <code>CanFly</code> mixins.</p>
<p>Overall, Decorators and Mixins are powerful features of TypeScript that allow you to add additional functionality to your classes, methods, and properties, and create new classes by combining existing ones.</p>
<h3 id="heading-async-and-await">Async and Await</h3>
<p>Async and Await in TypeScript allow you to write <strong>asynchronous</strong> code that looks like <strong>synchronous</strong> code:</p>
<pre><code class="lang-typescript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">wait</span>(<span class="hljs-params">ms: <span class="hljs-built_in">number</span></span>) </span>{
  <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-params">resolve</span> =&gt;</span> <span class="hljs-built_in">setTimeout</span>(resolve, ms));
}

<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">myAsyncFunction</span>(<span class="hljs-params"></span>) </span>{  <span class="hljs-comment">// this function is decleared with async keyword.</span>
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Start'</span>);
  <span class="hljs-keyword">await</span> wait(<span class="hljs-number">2000</span>);
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Middle'</span>);
  <span class="hljs-keyword">await</span> wait(<span class="hljs-number">2000</span>);
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'End'</span>);
}

myAsyncFunction();  <span class="hljs-comment">//here we are calling a function</span>
</code></pre>
<p>In this example, the <code>wait</code> function returns a Promise that resolves after the specified number of milliseconds. The <code>myAsyncFunction</code> function is declared with the <code>async</code> keyword, which means that it returns a Promise. Inside the function, we use the <code>await</code> keyword to wait for the Promises returned by the <code>wait</code> function.</p>
<p>When we call <code>myAsyncFunction</code>, it</p>
<ul>
<li><p>logs "<code>Start,</code>" waits for 2 seconds,</p>
</li>
<li><p>logs "Middle," waits for another 2 seconds, and</p>
</li>
<li><p>logs "End".</p>
<p>  The output of this function looks like synchronous code even though it's asynchronous under the hood.</p>
</li>
</ul>
<h2 id="heading-using-typescript-with-frameworks-and-libraries"><strong>Using TypeScript with Frameworks and Libraries</strong></h2>
<p>TypeScript can be used with a variety of frameworks and libraries. Here are some examples:</p>
<h3 id="heading-angular">Angular</h3>
<p><a target="_blank" href="https://angular.io/">Angular</a> is a popular web framework that is built with TypeScript:</p>
<pre><code class="lang-typescript">
<span class="hljs-meta">@Component</span>({
  selector: <span class="hljs-string">'app-root'</span>,
  templateUrl: <span class="hljs-string">'./app.component.html'</span>,
  styleUrls: [<span class="hljs-string">'./app.component.css'</span>]
})
<span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> AppComponent {
  title = <span class="hljs-string">'my-app'</span>;
}
</code></pre>
<h3 id="heading-react">React</h3>
<p><a target="_blank" href="https://react.dev/">React</a> is a popular UI library that can be used with TypeScript:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">interface</span> Props {
  name: <span class="hljs-built_in">string</span>;
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">MyComponent</span>(<span class="hljs-params">props: Props</span>) </span>{
  <span class="hljs-keyword">return</span> &lt;div&gt;Hello, {props.name}!&lt;/div&gt;;
}
</code></pre>
<h3 id="heading-nodejs">Node.js</h3>
<p><a target="_blank" href="https://nodejs.org/en">Node.js</a> is a popular runtime environment that can be used with TypeScript:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">import</span> * <span class="hljs-keyword">as</span> http <span class="hljs-keyword">from</span> <span class="hljs-string">'http'</span>;

http.createServer(<span class="hljs-function">(<span class="hljs-params">req, res</span>) =&gt;</span> {
  res.writeHead(<span class="hljs-number">200</span>, { <span class="hljs-string">'Content-Type'</span>: <span class="hljs-string">'text/plain'</span> });
  res.end(<span class="hljs-string">'Hello, TypeScript!'</span>);
}).listen(<span class="hljs-number">8080</span>);
</code></pre>
<h2 id="heading-best-practices-for-writing-typescript-code"><strong>Best Practices for Writing TypeScript Code</strong></h2>
<p>Here are some best practices for writing TypeScript code:</p>
<ul>
<li><strong>Consistent code formatting and naming conventions</strong></li>
</ul>
<p>Use consistent code formatting and naming convention to make your code easier to read and understand. Tools like <a target="_blank" href="https://prettier.io/">Prettier</a> and <a target="_blank" href="https://eslint.org/">ESLint</a> can help enforce these conventions.</p>
<ul>
<li><strong>Proper use of TypeScript types</strong></li>
</ul>
<p>Use TypeScript <code>types</code> to help catch errors before runtime and provide better editor support for your code. Use <code>interfaces</code> to define the shape of your objects.</p>
<ul>
<li><strong>Using third-party libraries with TypeScript</strong></li>
</ul>
<p>Always use TypeScript definitions for third-party libraries, guaranteeing smooth integration with your TypeScript code. You can install type definitions for popular libraries using npm, or use a tool like DefinitelyTyped to find and install them.</p>
<ul>
<li><strong>Type narrowing and guards</strong></li>
</ul>
<p>Type <code>narrowing and guards</code> are powerful features in TypeScript that allow you to write more precise and safer code.</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">interface</span> Cat {
  meow(): <span class="hljs-built_in">void</span>;
}

<span class="hljs-keyword">interface</span> Dog {
  bark(): <span class="hljs-built_in">void</span>;
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">isCat</span>(<span class="hljs-params">animal: Cat | Dog</span>): <span class="hljs-title">animal</span> <span class="hljs-title">is</span> <span class="hljs-title">Cat</span> </span>{
  <span class="hljs-keyword">return</span> <span class="hljs-string">'meow'</span> <span class="hljs-keyword">in</span> animal;
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">makeSound</span>(<span class="hljs-params">animal: Cat | Dog</span>) </span>{
  <span class="hljs-keyword">if</span> (isCat(animal)) {
    animal.meow();
  } <span class="hljs-keyword">else</span> {
    animal.bark();
  }
}
</code></pre>
<p>In TypeScript, a variable can have multiple possible types, such as the <code>animal</code> parameter in the example code that can be either a <code>Cat</code> or a <code>Dog</code>. When dealing with variables that can have multiple types, writing code that is specific to a particular type can be a challenging task.</p>
<p>This is where <code>type narrowing and guards</code> come into play. <strong>Type narrowing</strong> allows you to narrow down the type of a variable based on certain conditions so that TypeScript knows more precisely <code>what type the variable</code> is at a given point in your code. This can help catch errors and provide better editor support for your code.</p>
<p>In the example code, the <code>isCat</code> function is a <code>type guard</code> that takes an <code>animal</code> <code>parameter</code> that could be either a <code>Cat</code> or a <code>Dog</code>. It returns a boolean that indicates whether or not the <code>animal</code> parameter is a <code>Cat</code>. By using the <code>animal is Cat</code> syntax in the function signature, we're telling TypeScript that this function is a <code>type guard</code> that narrows down the <code>animal</code> parameter to the <code>Cat</code> type.</p>
<p>The <code>makeSound</code> function takes an <code>animal</code> <code>parameter</code> that could be either a <code>Cat</code> or a <code>Dog</code>. Inside the function, we use the <code>isCat</code> function as a guard to check if the <code>animal</code> parameter is a <code>Cat</code>. If it is, we call the <code>meow</code> method on the <code>animal</code>. Otherwise, we call the <code>bark</code> method on the <code>animal</code>.</p>
<p>Using <code>type guards and narrowing</code> allows us to write more precise and safer code, catching errors at compile time rather than runtime. By telling TypeScript more about the types of our variables, we can leverage the full power of TypeScript's type system to make our code more robust and easier to maintain.</p>
<ul>
<li><strong>Using TypeScript with testing frameworks</strong></li>
</ul>
<p>Testing frameworks like Jest and Cypress can be used with TypeScript to write more robust and type-safe tests:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">import</span> { sum } <span class="hljs-keyword">from</span> <span class="hljs-string">'./my-module'</span>;

describe(<span class="hljs-string">'sum'</span>, <span class="hljs-function">() =&gt;</span> {
  it(<span class="hljs-string">'should add two numbers together'</span>, <span class="hljs-function">() =&gt;</span> {
    expect(sum(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>)).toEqual(<span class="hljs-number">3</span>);
  });
});
</code></pre>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>TypeScript is a powerful tool that can help you write more robust, maintainable, and scalable JavaScript code. It provides several useful features like type checking, interfaces, decorators, and async/awaits that can help catch errors early, improve code readability, and increase productivity. By embracing best practices and using TypeScript with well-known frameworks and libraries, you'll boost your web development skills to impressive levels. So, get started with TypeScript today and take your coding skills to the next level!</p>
<p>If you found this article helpful, don't forget to give it a thumbs up, follow <a target="_blank" href="https://reactplay.hashnode.dev/">ReactPlay Blogs</a>, and share it with your friends and colleagues. If you have any questions or feedback, feel free to leave a comment below. You can also connect with me on <a target="_blank" href="https://twitter.com/Shivamkatare_27">Twitter</a>, <a target="_blank" href="https://www.linkedin.com/in/shivam-katare-aa80b218b/">LinkedIn</a>, and <a target="_blank" href="https://www.showwcase.com/shivam-katare">ShowwCase</a> for more updates and helpful resources on web development. Thank you for reading!</p>
]]></content:encoded></item><item><title><![CDATA[Importance of Content Creation]]></title><description><![CDATA[Content creation is the process of creating and sharing relevant, useful and consistent content to attract and retain a clear audience. Businesses can engage with their audience and boost their reputation by creating good content.
Some useful tips be...]]></description><link>https://blog.reactplay.io/importance-of-content-creation</link><guid isPermaLink="true">https://blog.reactplay.io/importance-of-content-creation</guid><category><![CDATA[Blogging]]></category><category><![CDATA[General Advice]]></category><category><![CDATA[ReactPlay]]></category><category><![CDATA[#react-play-anniversary-23]]></category><dc:creator><![CDATA[Yuvraj Sharma]]></dc:creator><pubDate>Fri, 14 Apr 2023 02:19:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1681401875897/958367f2-6a68-4bdc-914a-b2d1247ba3fc.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Content creation is the process of creating and sharing relevant, useful and consistent content to attract and retain a clear audience. Businesses can engage with their audience and boost their reputation by creating good content.</p>
<p>Some useful tips becoming a good content creator :-</p>
<p>Define Your Audience: It is important to define your target audience before creating content. Understanding your audience's needs and preferences will help you create content that appeals to them.</p>
<p>Create useful content: Your content should be useful to your target audience. This can be knowledge, insight or entertainment. By creating relevant content, you engage your audience and gain their trust.</p>
<p>Promote Your Content: Promoting your content is crucial to growing your audience. This may include sharing your content via social media, email marketing or paid advertising.</p>
<p>Conclusion :- Content creation is the key to successful online marketing. By creating quality content that benefits your audience, you can attract and retain customers, build brand awareness, and position yourself as an industry leader in your business process. By following the best practices outlined in this blog, you can create content that resonates with your audience and achieves your marketing goals.</p>
<p>#react-play-anniversary-23 </p>
<p>#react-play-anniversary-23</p>
]]></content:encoded></item><item><title><![CDATA[ReactPlay presents #2PlaysAMonth for Web Developers]]></title><description><![CDATA[Hey There 👋
ReactPlay presents an exciting event #2PlaysAMonth for ReactJS/Web Developers to learn, build, and share. Oh yeah! Also to win some exciting prizes, too.
The event starts Feb 1st 2023 and ends on Feb 28th 2023. You will be building 2 pro...]]></description><link>https://blog.reactplay.io/reactplay-presents-2playsamonth-for-web-developers</link><guid isPermaLink="true">https://blog.reactplay.io/reactplay-presents-2playsamonth-for-web-developers</guid><category><![CDATA[hackathon]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[React]]></category><category><![CDATA[General Programming]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Tapas Adhikary]]></dc:creator><pubDate>Fri, 03 Feb 2023 04:26:25 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1675397687033/9c100259-efd0-4741-b282-e5c8c93fa575.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hey There 👋</p>
<p>ReactPlay presents an exciting event <code>#2PlaysAMonth</code> for ReactJS/Web Developers to learn, build, and share. Oh yeah! Also to win some exciting prizes, too.</p>
<p>The event starts <code>Feb 1st 2023</code> and ends on <code>Feb 28th 2023</code>. You will be building 2 projects in these 28 days on any ideas of your choice! You need to follow a few rules that you can find here:</p>
<blockquote>
<p><a target="_blank" href="https://hustles.reactplay.io">#2PlaysAMonth Event from ReactPlay</a></p>
</blockquote>
<h2 id="heading-how-to-participate">How to Participate?</h2>
<ul>
<li><p>You must complete two plays(React Projects) on ReactPlay between February 1st to February 28th 2023.</p>
</li>
<li><p>You must follow the <a target="_blank" href="https://github.com/reactplay/react-play/blob/main/CREATE-PLAY.md">Create a Play</a> steps to create the play. Please <a target="_blank" href="https://github.com/reactplay/react-play/issues/new?assignees=&amp;labels=%232PlaysAMonth&amp;template=%232PlaysAMonth.yml&amp;title=%5B%232PlaysAMonth%5D%3A+">create an issue</a> on the ReactPlay repository for each pull request.</p>
</li>
<li><p>Your play must have <code>#2PlaysAMonth</code> tag added to it while creating.</p>
</li>
<li><p>You can build any project of your choice. If you are looking for ideas, <a target="_blank" href="https://reactplay.io/ideas">here are some you can get inspired by</a>.</p>
</li>
<li><p>You must register on <a target="_blank" href="https://www.stack-stream.com/">stackstream</a>.</p>
</li>
<li><p>Create a demo on <a target="_blank" href="https://www.stack-stream.com/">stackstream</a> explaining your work and add the recording link to your play by editing it.</p>
<p>  That's it, and you are all set to go.</p>
</li>
</ul>
<h2 id="heading-about-reactplay">About <code>ReactPlay</code></h2>
<p><code>ReactPlay</code> is an Open Source platform that helps anyone learn ReactJS faster with a hands-on practice model. It is a collection of ReactJS projects you can use to learn ReactJS.</p>
<p>Is that all? Nope. You can also create your projects and share them with the world. The best part is that ReactJS <code>experts</code> will review your project code before it gets part of the ReactPlay platform. Isn't that a pure WIN-WIN?</p>
<h2 id="heading-important-links">Important Links</h2>
<ul>
<li><p><a target="_blank" href="https://reactplay.io/">ReactPlay Website</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/reactplay">ReactPlay Org on GitHub</a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/ReactPlayIO">ReactPlay on Twitter</a></p>
</li>
<li><p><a target="_blank" href="https://discord.gg/vrTxWUP8Am">ReactPlay Community on Discord</a></p>
</li>
<li><p><a target="_blank" href="https://blog.reactplay.io/">ReactPlay Blog</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Seven Ways To Share Knowledge In Tech]]></title><description><![CDATA[In today's fast-paced technology landscape, sharing knowledge and collaborating with others is the key to staying ahead of the curve and driving innovation. Whether you're a beginner or an expert, sharing your knowledge with others can help you grow ...]]></description><link>https://blog.reactplay.io/seven-ways-to-share-knowledge-in-tech</link><guid isPermaLink="true">https://blog.reactplay.io/seven-ways-to-share-knowledge-in-tech</guid><category><![CDATA[Career]]></category><category><![CDATA[community]]></category><category><![CDATA[Open Source]]></category><category><![CDATA[ReactPlay]]></category><dc:creator><![CDATA[Shivam Katare]]></dc:creator><pubDate>Sun, 29 Jan 2023 13:38:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1674962936125/97a5d178-e03b-4621-b932-ffd63e68f5d1.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In today's fast-paced technology landscape, sharing knowledge and collaborating with others is the key to staying ahead of the curve and driving innovation. Whether you're a beginner or an expert, sharing your knowledge with others can help you grow in your career and contribute to the industry's development.</p>
<p>This blog post will dive deep into the various ways to share your knowledge and expertise in the tech industry. From writing technical articles and giving presentations, to teaching and mentoring, to collaborating on open-source projects and participating in online communities, we will explore the different methods of sharing knowledge and how they can benefit your personal and professional growth.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674910860518/28eaff4d-63cf-4dcb-a736-4e88a3cf7dff.png" alt class="image--center mx-auto" /></p>
<p>Finally, we will understand the importance of staying updated and actively sharing knowledge and insights in the tech industry, and how it can contribute to the field's advancement. So, get ready to unlock the full potential of your knowledge and take the first step toward becoming a thought leader in the tech industry!</p>
<h2 id="heading-writing">Writing</h2>
<p>Writing technical articles is a great way to share your knowledge of technology. By creating well-written, informative articles on technical topics, you can help others to gain a deeper understanding of the subject and learn from your experience and expertise. You can publish these articles on your blog or website, on platforms such as <strong>Hashnode</strong>, or even contribute to platforms like <a target="_blank" href="https://blog.reactplay.io/">ReactPlay</a> where you can share your knowledge and collaborate with others in the community.</p>
<p><img src="https://media1.giphy.com/media/VIKOfvqJHcVDrdVivT/giphy.gif?cid=ecf05e47kv0dmdv1y0upmryvv0jdw8tvxhfsixyie8tu8wcf&amp;rid=giphy.gif&amp;ct=g" alt="Studying College Life GIF by Emmelinedraws" class="image--center mx-auto" /></p>
<p><strong>There are several benefits to writing technical articles:</strong></p>
<ul>
<li><p>Writing helps to clarify your thoughts and understanding of a topic. As well as to organize your ideas logically.</p>
</li>
<li><p>It helps to establish you as an authority on the topic and positions you as a thought leader in the industry.</p>
</li>
<li><p>Technical articles are a great way to reach an audience, as they can be easily shared and accessed online.</p>
</li>
<li><p>It is an effective technique to demonstrate your knowledge, skills, and expertise in a particular subject or technology to potential employers or clients.</p>
</li>
</ul>
<h2 id="heading-presenting">Presenting</h2>
<p>Presenting is one of the most effective ways to share your knowledge of technology. Giving presentations on technical topics allows you to communicate complex information clearly and concisely, making it easily accessible to others. Presentations can happen in several settings, including conferences, meetups, and internal company events.</p>
<p><img src="https://media1.giphy.com/media/xT8qAZGxbW2JtDNnO0/giphy.gif?cid=ecf05e471fhwyz88fahilqvr7m59o36g5yqpqhzz1pggjal3&amp;rid=giphy.gif&amp;ct=g" alt="presentation GIF by elfemmit headband" class="image--center mx-auto" /></p>
<p>When giving a presentation, make sure your audience and tailor your content to their level of understanding. Start with an overview of the topic and build up to more details. Use visuals, such as slides or diagrams, to help explain the information and keep the audience engaged. Practice your delivery and timing to ensure that your presentation flows smoothly and that you stay within the allotted time.</p>
<p>Sharing your knowledge through presentations also allows you to establish yourself as a thought leader in the industry. It can help you gain visibility and credibility, which can open up new opportunities for career advancement.</p>
<h2 id="heading-teaching">Teaching</h2>
<p>The 3rd way is teaching. When you teach someone, you are not only sharing your knowledge but also helping them understand and internalize the information. Teaching is not only beneficial for the person being taught but also for the person doing the teaching. It allows you to deepen your understanding of a subject and helps to reinforce your knowledge and skills. Additionally, teaching positions typically require constant learning, so it can be a great way to stay updated with the latest trends and technologies.</p>
<p><img src="https://media1.giphy.com/media/l0MYLE9bob7mhosfu/giphy.gif?cid=ecf05e47pi8umvkyj3gf2lwmls9n1cnedj8nug1tg1krxrt4&amp;rid=giphy.gif&amp;ct=g" alt="frank costanza seinfeld GIF by HULU" class="image--center mx-auto" /></p>
<h2 id="heading-social-media">Social Media</h2>
<p>Social media is a powerful tool for sharing knowledge in technology. Platforms like Twitter, LinkedIn, and ShowwCase allow professionals in the tech industry to connect, share information, and engage in discussions about the latest advancements and trends in their field. Some ways to use social media for sharing knowledge in tech include:</p>
<p><img src="https://media2.giphy.com/media/11kUypQPRKlIkw/giphy.gif?cid=ecf05e47vdkunv155n836juy5dm3z9h908b7cdfn3cw3209v&amp;rid=giphy.gif&amp;ct=g" alt="social GIF" class="image--center mx-auto" /></p>
<ul>
<li><p>Sharing updates and insights about your work and projects on <strong>LinkedIn, Twitter, and ShowwCase</strong> can help others learn about new technologies and techniques.</p>
</li>
<li><p>Participating in <strong>Twitter</strong> chats and discussion groups related to your field can provide a platform for sharing knowledge and engaging in conversations with other professionals.</p>
</li>
<li><p>Writing a blog and sharing it on platforms like <strong>Hashnode</strong> with the communities like ReactPlay and <a target="_blank" href="https://fuelerhq.hashnode.dev/">Fueler</a>.</p>
</li>
<li><p>Building a personal brand on social media platforms and sharing knowledge through this medium.</p>
</li>
</ul>
<h2 id="heading-online-communities">Online Communities</h2>
<p>Online communities are a great way to share knowledge and collaborate with others in tech. These communities can be found on various platforms such as forums, social media groups, and messaging apps, and they frequently concentrate on specific technologies or topics. Participating in online communities can provide a wealth of benefits, including:</p>
<p><img src="https://media2.giphy.com/media/mGo8dkPOF6GLm/giphy.gif?cid=ecf05e47b9euoeus0o24n8r1288vnst3euzwk1cctfvp0h39&amp;rid=giphy.gif&amp;ct=g" alt="Handshake GIF" class="image--center mx-auto" /></p>
<ol>
<li><p>Access to experts: Online communities often attract experts in various fields, and by participating in these communities, you can learn from the best and ask questions to further your knowledge.</p>
</li>
<li><p>Networking opportunities: Online communities such as <a target="_blank" href="https://twitter.com/ReactPlayIO">ReactPlay</a>, <a target="_blank" href="https://twitter.com/WeMakeDevs">WeMakeDevs</a>, and <a target="_blank" href="https://twitter.com/eddiejaoude">EddieHub</a> can provide opportunities to connect with other professionals in our field, which can be beneficial for building relationships and finding job opportunities.</p>
</li>
<li><p>Collaboration and problem-solving: Participating in online communities can also provide opportunities to collaborate on projects, troubleshoot problems, and share solutions with others.</p>
</li>
<li><p>Keeping up with the latest trends: Online communities can also be a great way to stay up-to-date with the latest developments and trends.</p>
</li>
<li><p>Giving back: Participating in online communities can also be a way to give back and help others. Whether you are answering questions, providing feedback, or mentoring, you can make a genuine difference in the community.</p>
</li>
</ol>
<h2 id="heading-open-source-contribution">Open-source contribution</h2>
<p>Open-source contribution is a way of sharing knowledge in tech by contributing to open-source projects. Open-source projects are software projects that are publicly available and can be modified and distributed by anyone. By contributing to open-source projects like <a target="_blank" href="https://github.com/reactplay/react-play">ReactPlay</a>, and <a target="_blank" href="https://github.com/EddieHubCommunity/LinkFree">LinkFree</a>, individuals can share their knowledge and skills with a wider community while learning from others.</p>
<p><img src="https://media3.giphy.com/media/dxn6fRlTIShoeBr69N/giphy.gif?cid=ecf05e4773ga4favv1gqkt3q9gcqfgfqyyhaq3ir17t2l4gg&amp;rid=giphy.gif&amp;ct=g" alt="Tech GIF by Hacker Noon" class="image--center mx-auto" /></p>
<p>There are many ways to contribute to open-source projects, depending on the project and the individual's skills and interests. Some examples include</p>
<ol>
<li><p>Writing Code</p>
</li>
<li><p>Writing Documentation</p>
</li>
<li><p>Proving Translations</p>
</li>
<li><p>Testing</p>
</li>
<li><p>Participating in community</p>
</li>
<li><p>And much more.</p>
</li>
</ol>
<h2 id="heading-consulting">Consulting</h2>
<p>Consulting is a way to share your knowledge of technology by providing expert advice and guidance to organizations and businesses. As a consultant, you will use your technical expertise and industry experience to help clients solve problems, improve processes, and achieve their goals.</p>
<p>Consulting can take many forms, from working as an independent consultant to being part of a consulting firm. As a beginner, I never tried consulting. So, I can't give much on this topic.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In conclusion, there are many ways to share knowledge in tech and make a positive impact on the industry. We've discussed the benefits of writing technical articles, giving presentations, teaching and mentoring, collaborating on open-source projects, participating in online communities, and consulting. I hope you found this blog informative and encouraged you to start sharing your knowledge in tech. Thank you for reading!</p>
<p>You can join me on socials where we can learn and grow together :)</p>
<ul>
<li><p><a target="_blank" href="https://www.showwcase.com/shivam-katare">ShowwCase</a></p>
</li>
<li><p><a target="_blank" href="https://www.linkedin.com/in/shivam-katare-aa80b218b/">LinkedIn</a></p>
</li>
<li><p><a target="_blank" href="https://mobile.twitter.com/Shivamkatare_27">Twitter</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/Shivam-Katare">GitHub</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[React Play: a Retrospective of 2022]]></title><description><![CDATA[Hello, and welcome to our first blog of 2023! 🥳🎆
First, we wish you a happy new year from our ReactPlay community! We hope this year brings all the positive changes you deserve.
The previous year has been absolutely fantastic for us. We want to sha...]]></description><link>https://blog.reactplay.io/reactplay-2022-retrospective</link><guid isPermaLink="true">https://blog.reactplay.io/reactplay-2022-retrospective</guid><category><![CDATA[ReactPlay]]></category><category><![CDATA[community]]></category><category><![CDATA[Open Source]]></category><category><![CDATA[General Programming]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Kaushal Joshi]]></dc:creator><pubDate>Fri, 20 Jan 2023 09:07:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1674140180558/44154a6d-79a3-4bbe-892b-efd8e9ed72ae.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello, and welcome to our first blog of 2023! 🥳🎆</p>
<p>First, we wish you a happy new year from our ReactPlay community! We hope this year brings all the positive changes you deserve.</p>
<p>The previous year has been absolutely fantastic for us. We want to share everything with you through this blog. Consider it a retrospective of the year 2022.</p>
<h2 id="heading-hello-world">Hello, World!</h2>
<p>We wanted to build a community for Web developers, especially beginners focusing on the front end to learn, develop and grow their skillset. Hence, we created ReactPlay, an open-source project to learn project-based programming with a hands-on model.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://twitter.com/ReactPlayIO/status/1514840886576033792">https://twitter.com/ReactPlayIO/status/1514840886576033792</a></div>
<p> </p>
<p>We truly kicked off in April 2022. And soon enough, gain a lot of traction, and developers from around the globe joined us.</p>
<h2 id="heading-the-first-play">The First Play</h2>
<p>'Plays' are the foundation of the ReactPlay platform. As you know by now, we are a project-based learning platform. Everything revolves around projects that contributors develop.</p>
<p>Each project submission is called a <em>Play</em> in ReactPlay. Contributors can submit their plays and get reviewed by experienced developers.</p>
<p>Our first project was created on 3rd April 2022. It was a play called <a target="_blank" href="https://reactplay.io/plays"><strong>Why React</strong></a> contributed by <a target="_blank" href="https://twitter.com/tapasadhikary">Tapas Adhikary</a>, demonstrating why one should choose React.js.</p>
<p>Throughout the year, many contributors joined us. By the year's end, we had more than 60 projects on our platform.</p>
<p>Explore new plays <a target="_blank" href="https://reactplay.io/plays">here</a>.</p>
<h2 id="heading-the-community">The Community</h2>
<p>Initially, we started a Twitter group with contributors. But as more developers started contributing, we needed something better. As a result, we created a <a target="_blank" href="https://discord.com/channels/982239924227031070/983060307175960586">discord server</a> to interact with other community members. We were already active on <a target="_blank" href="https://twitter.com/ReactPlayIO">Twitter</a> by then. And soon enough, we launched our <a target="_blank" href="https://www.linkedin.com/company/reactplay/">LinkedIn</a> page as well.</p>
<p>Discord is the place where all the fun begins. The community calls, discussions, chats, memes, announcements, and everything is majorly conducted through our Discord server. As of today, we have more than 400 active members on Discord.</p>
<p><img src="https://pbs.twimg.com/media/FUkb7nPUcAIbwvz?format=jpg&amp;name=large" alt /></p>
<p>We primarily host spaces on Twitter. We talk about <code>[THINGS WE TALK ABOUT]</code>. Additionally, we share insightful and informative content on both Twitter and LinkedIn. We share quizzes, quotes, trips and tricks, and much more. We have more than 2,000 friends on the blue bird app and about 500 followers on LinkedIn.</p>
<h2 id="heading-the-blog">The Blog</h2>
<p>We decided to expand our horizons and step into different areas of software development. Blogging, though not directly connected with development, has an integral role in the developer's journey. Therefore we decided to start a blog.</p>
<p>We started the <a target="_blank" href="https://blog.reactplay.io/">ReactPlay blog</a> on 23rd June 2023. We encouraged everyone to write about their experiences and learnings. People began writing about creating plays, building personal projects, difficulties faced open source, and many other topics.</p>
<p>We got a positive response from everyone. Today, we have about 50 blogs published on a variety of topics, including but not limited to React, JavaScript, Open source, Git and GitHub.</p>
<h2 id="heading-hack-r-play">Hack-R-Play</h2>
<p>Another milestone we achieved is our first-ever hackathon!</p>
<p>We hosted <a target="_blank" href="https://hustles.reactplay.io/hackrplay/2022/home">Hack-R-Play</a> in October 2022. NHost happily sponsored it. Participants had to create an open-source project using NHost and any React-based technology. Later they had to write a blog and submit it along with the original project.</p>
<p>The hackathon received 82 submissions in total. Seventeen of those projects were completed. Finally, we selected three grand prize winners.</p>
<p>Read more about Hack-R-Play in our separate <a target="_blank" href="https://blog.reactplay.io/announcing-hack-r-play-hackathon-from-react-play">blog</a>, and <a target="_blank" href="https://blog.reactplay.io/hack-r-play-winner-announcement">check this out</a> to see who won the hackathon.</p>
<h2 id="heading-no-mess-november">No Mess November</h2>
<p>The codebase became cluttered as more contributors started contributing to the project. We have made a plethora of changes in the codebase since day one.</p>
<p>To make things easier to develop, build and maintain; we made some significant changes in our codebase.</p>
<p>To begin, we divided the platform's functionality into separate repositories. Next, we introduced authentication, made the play-creation process easier, and added play interaction and modification capabilities.</p>
<p>In November 2022, we followed No Mess November. We cleaned up the entire codebase and configured ESLint and Prettier to have opinioned rules for everyone.</p>
<p>It was a hectic task since we had to clean up the existing codebase and create a system for new contributions. But our fellow contributors collaborated and cleaned up the entire codebase.</p>
<p>Code cleanup witnessed the community's most extensive collaboration, where everybody helped fix some part of the codebase.</p>
<h2 id="heading-reactplay-live">ReactPlay Live</h2>
<p>The third and most recent achievement of our community is ReactPlay Live. We encouraged developers to write, build and showcase. But what after that?</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://www.youtube.com/watch?v=1qfDkmtuWqg">https://www.youtube.com/watch?v=1qfDkmtuWqg</a></div>
<p> </p>
<p>On ReactPlay Live, we call a community member over YouTube live to share their journey and experiences in the domain. This helps both beginner and intermediate members to upskill themselves. At the same time, the guest gets an opportunity to share their story, talk in front of the audience and build public speaking confidence.</p>
<p>We have covered topics such as Jobs, interview preparations, and full-stack development.</p>
<h2 id="heading-the-foss-india-participation">The FOSS India Participation</h2>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://www.youtube.com/watch?v=VQoikj4yRng">https://www.youtube.com/watch?v=VQoikj4yRng</a></div>
<p> </p>
<p>FOSS is a celebration of Open Source. We had a representation of ReactPlay in the Foss India 2.0 help in Bangalore, India. We spoke about the project's vision, community, and the approach we are taking to make learning easy.</p>
<p>It was very well received, with a lot of positive feedback.</p>
<h2 id="heading-the-present">The Present</h2>
<p>We are so proud of what we have achieved in such a short time. Today, we have about 600 starts, more than 300 forks, and more than 75 contributors to our GitHub Repository.</p>
<p>This must have only been possible with all of our community members. We thank everyone for connecting with us, engaging in the community, and participating in various activities.</p>
<p>We recently crossed 600 stars in our repository. If you haven't starred it yet, this is the perfect time to do it!</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://github.com/reactplay/react-play">https://github.com/reactplay/react-play</a></div>
<p> </p>
<h2 id="heading-the-future">The Future</h2>
<p>In 2023, we have grand plans to take the project to the next level with a community-first approach.</p>
<p>Here is a short brief on what we have been brainstorming for this year:</p>
<ul>
<li><p>User Interface revamp</p>
</li>
<li><p>User profile page</p>
</li>
<li><p>Leaderboard</p>
</li>
<li><p>Follow creators</p>
</li>
</ul>
<p>As per community engagement goes, we have exciting plans for this year.</p>
<ul>
<li><p>In-person meetup (Stay tuned for this!) You would surely love those:</p>
</li>
<li><p>More engagement on RaectPlay Live to provide a platform for every beginner who wants to share their journey.</p>
</li>
<li><p>Web Development Workshops</p>
</li>
<li><p>Project-based Cohort</p>
</li>
</ul>
<p>This is just the icing on the cake! There are many other things that we are planning for this year. Please ensure you are part of our community and follow us on the blue bird app for the latest updates.</p>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>That's it for today! We hope you had a fantastic year and are still sticking with your new year's resolutions. All the best for the upcoming year.</p>
<p>If you want to connect with us, here we are:</p>
<ul>
<li><p><a target="_blank" href="https://github.com/reactplay/react-play">GitHub</a></p>
</li>
<li><p><a target="_blank" href="https://discord.com/invite/vrTxWUP8Am">Discord</a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/reactplayio">Twitter</a></p>
</li>
<li><p><a target="_blank" href="https://blog.reactplay.io/">HashNode</a></p>
</li>
</ul>
<p>Until then, keep contributing!</p>
]]></content:encoded></item><item><title><![CDATA[Persistent Log in using Cookies in React]]></title><description><![CDATA[Introduction
It's a hassle to login into applications such as social media, youtube, and GitHub which are visited by users regularly, mostly multiple times in a single day. No one wants to keep entering the same credentials every time they wish to us...]]></description><link>https://blog.reactplay.io/persistent-log-in-using-cookies-in-react</link><guid isPermaLink="true">https://blog.reactplay.io/persistent-log-in-using-cookies-in-react</guid><category><![CDATA[React]]></category><category><![CDATA[cookies]]></category><category><![CDATA[General Programming]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Abhishek Holani]]></dc:creator><pubDate>Fri, 02 Dec 2022 09:38:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1669741243308/Ijm1LDv8M.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>It's a hassle to login into applications such as social media, youtube, and GitHub which are visited by users regularly, mostly multiple times in a single day. No one wants to keep entering the same credentials every time they wish to use an application.</p>
<p>Persistent login takes care of this hassle as it stores these credentials in a secure form in the user's device only(in browsers in the case of web apps) and uses them to substitute entering the credentials to log in and use the application.</p>
<p>These secured credentials can be stored in the user's device in Local Storage and as Cookies.</p>
<blockquote>
<p>Note: Session Storage is not recommended to store these credentials as the storage clears itself as soon as the session ends.</p>
</blockquote>
<p>Here, we will be using cookies to store the credentials and implement our persistent login feature inside our React Application. We will be using React for Frontend and NodeJS(Express framework) for the back end.</p>
<p>Before we jump into creating our persistent login feature, if you are not familiar with cookies, you can read about cookies <a target="_blank" href="https://www.educative.io/blog/http-cookies">here</a>.</p>
<h2 id="heading-implementation">Implementation</h2>
<p>Now let us begin with the implementation. For the demo purpose, we will create a small application without databases. The idea is simple. The user will add the credentials and these credentials will be sent to the server from where we will receive our cookie. There is no sign-up required. As long as the cookie is valid/present, the user won't have to log in again.</p>
<h3 id="heading-backend-implementation">Backend Implementation</h3>
<p>First, let us begin with creating our server.</p>
<p>Create a folder named Persistent-Login. In this folder, you will have your separate backend and frontend folders. Create a folder inside Persistent-login named Backend. Now open this Backend folder in your favorite editor(I will use VSCode). Open a terminal inside VSCode and follow the below steps.</p>
<p><strong>Installing packages</strong> Execute the following commands in the terminal:</p>
<pre><code class="lang-bash">npm init -y  

npm i nodemon express jsonwebtoken cors

npm i
</code></pre>
<p>Add the below lines of code to your <code>package.json</code></p>
<pre><code class="lang-plaintext">"scripts": {
    "start": "nodemon index.js"
 },
</code></pre>
<p>After this, your <code>package.json</code> should look like the below image:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1668076736550/u7W23GyfJ.jpg" alt="package.jpg" class="image--center mx-auto" /></p>
<p>Now create a file name index.js in the root of your backend and add the below lines of code inside it.</p>
<pre><code class="lang-plaintext">// index.js
const express = require("express");
const jsonwebtoken = require("jsonwebtoken");
const cors = require("cors");
const app = express();

app.use(express.json()); //allowing json data to be received from client

// here we are setting up cors so that we can make requests from cross-origin resources
app.use(
  cors({
    origin: "http://localhost:3000",
    credentials: true,
    allowedHeaders: [
      "set-cookie",
      "Content-Type",
      "Access-Control-Allow-Origin",
      "Access-Control-Allow-Credentials",
    ],
  })
);

// this is the default path. Go to `localhost:5000` on your browser to check if your server is running
app.get("/", (req, res) =&gt; {
  res.json({ Message: "Server is up and running" });
});

// this is the login path
app.post("/login", (req, res) =&gt; {
  const id = req.body?.id;
  const password = req.body?.password;
  const authToken = jsonwebtoken.sign({ id, password }, "DUMMYKEY");

  // now we will be setting cookies from server side only.
  // below cookie is httpOnly, its maxAge is 1 day
  // This cookie is valid to all the path in the domain
  res.cookie("authToken", authToken, {
    path: "/",
    maxAge: 24 * 60 * 60 * 1000,
    httpOnly: true,
  });

  res.sendStatus(200);
});

// this path will be used to check if the cookie is valid to auto login inside the application;
app.get("/autoLogin", (req, res) =&gt; {
  const cookie = req.headers.cookie;

  // if we received no cookies then user needs to login.
  if (!cookie || cookie === null) {
    return res.sendStatus(401);
  }

  return res.sendStatus(200);
});

// this path will be used to check if the cookie is valid to auto login inside the application;
app.get("/logout", (req, res) =&gt; {
  res.clear("authToken");
  return res.sendStatus(200);
});

app.listen(5000, () =&gt; console.log("Backend Running on Port 5000"));
</code></pre>
<p>Now, open your terminal, go to your backend folder, run the following command and go to <code>http://localhost:5000</code></p>
<pre><code class="lang-bash">npm run start
</code></pre>
<blockquote>
<p>Note: In the above code for the <code>/AutoLogin</code> path, I have not implemented any authentication checks for the validity of the authToken and the internal details of the decrypted token. When you implement Auto Login in your application, please add the necessary checks as per your requirements.</p>
</blockquote>
<h2 id="heading-frontend-implementation">Frontend Implementation</h2>
<p>Now, let us begin with frontend implementation.</p>
<p>In your Persistent-Login folder, run the following command, and open frontend folder in your editor:</p>
<pre><code class="lang-plaintext">npx create-react-app frontend
</code></pre>
<p>Inside <code>/src</code> folder of the root frontend folder, clear the file <code>index.css</code> &amp; inside <code>App.js</code>, clear the code inside <code>div</code> with class <code>App</code>.</p>
<p>In this project, we will add only 2 basic components, one will be used to enter user credentials to login and receive cookies and the second will show that the user is logged in and can logout to delete the cookie.</p>
<p>Inside <code>/src</code> folder, create a folder <code>components</code>, and inside <code>components</code>, create folders Login and Homepage. Inside <code>/Login</code> folder, create <code>Login.js</code>. Inside <code>/Homepage</code> folder, create <code>Homepage.js</code>.</p>
<h3 id="heading-loginjs"><code>Login.js</code></h3>
<p>Open Login.js and add the below code inside it. Here we have a basic layout consisting of 2 input fields for email id and password, and one submit button. Once you login with credentials, you are redirected to homepage. We have used an <code>useEffect</code> hook below to implemented <code>auto-login</code> i.e. persistent login. When the Login page is loaded, the useEffect hook makes call to <code>autoLogin</code> endpoint on backend. In this request the cookie is also transfered and if server returns a proper response, the user is directly redirected to homepage without adding credentials.</p>
<pre><code class="lang-plaintext">// Login.js

import React, { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";

function Login() {
  const [userInfo, setuserInfo] = useState({ id: "", password: "" });
  const handleOnChange = (e) =&gt; {
    setuserInfo({ ...userInfo, [e.target.name]: e.target.value });
  };
  const navigate = useNavigate();

  useEffect(() =&gt; {
    async function autoLogin() {
      const response = await fetch("http://localhost:5000/autoLogin", {
        method: "GET",
        credentials: "include",
      });
      if (response.status === 200) {
        navigate("/homepage");
      } else {
        navigate("/");
      }
    }
    autoLogin();
  }, []);

  const submit = async (e) =&gt; {
    e.preventDefault();

    if (userInfo.id.trim().length &gt; 0 &amp;&amp; userInfo.password.trim().length &gt; 0) {
      const response = await fetch("http://localhost:5000/login", {
        method: "POST",
        credentials: "include",
        headers: {
          "Content-type": "application/json",
        },
        body: JSON.stringify({
          id: userInfo.id,
          passsord: userInfo.password,
        }),
      });
      if (response.status === 200) {
        navigate("/homepage");
      }
    }
  };

  return (
    &lt;div className="container"&gt;
      &lt;input
        className="input"
        name="id"
        type="text"
        placeholder="Enter ID"
        onChange={(e) =&gt; handleOnChange(e)}
      /&gt;
      &lt;input
        className="input"
        name="password"
        type="password"
        placeholder="Enter password"
        onChange={(e) =&gt; handleOnChange(e)}
      /&gt;
      &lt;button className="btn" type="button" onClick={(e) =&gt; submit(e)}&gt;
        Login
      &lt;/button&gt;
    &lt;/div&gt;
  );
}

export default Login;
</code></pre>
<h3 id="heading-homepagejs"><code>Homepage.js</code></h3>
<p>Now, open <code>Homepage.js</code> file and add the below code. Here we have a logout button, once we click it, we are redirected to Login page and the cookie is also destroyed from the browser. Now if user goes to Login page, they need to login again, to go Homepage.</p>
<pre><code class="lang-plaintext">import React from "react";
import { useNavigate } from "react-router-dom";

function Homepage() {
  const navigate = useNavigate();
  async function logout() {
    const response = await fetch("http://localhost:5000/logout", {
      method: "GET",
      credentials: "include",
    });

    if (response.status === 200) {
      navigate("/");
    }
  }

  return (
    &lt;div className="container"&gt;
      &lt;p&gt;This is Homepage, Welcome!&lt;/p&gt;
      &lt;button className="btn" onClick={logout}&gt;
        Logout
      &lt;/button&gt;
    &lt;/div&gt;
  );
}

export default Homepage;
</code></pre>
<p>If you want to check your cookies, you can open your Developers tools and go to Application Tab -&gt; Cookies. You can find your cookie inside <code>http://localhost:3000</code> domain.</p>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>This above implementation is just a dummy demo. There are still many things you should implement to use this Persistent login feature in your applications.</p>
<ol>
<li><p>Implement a cookie parser to work with multiple cookies.</p>
</li>
<li><p>Once you get authtoken, you can decrypt it and check your database for user credentials.</p>
</li>
</ol>
<p>... so on</p>
<p>You can also find the entire code base on these given repositories, <a target="_blank" href="https://github.com/Abhishek-90/Persistent-Login-frontend">Frontend</a> &amp;&amp; <a target="_blank" href="https://github.com/Abhishek-90/Persistent-Login-backend">Backend</a></p>
<p>The frontend repository also contains some CSS code like <code>Login.styled.css</code> and <code>Homepage.styled.css</code>. However, these files are optional in this implementation as the main motive here is to understand persistent login using cookies.</p>
<p>Thank you!</p>
]]></content:encoded></item><item><title><![CDATA[Optimising Performance of a React Application]]></title><description><![CDATA[Optimisation is the number one thing on every dev's mind when building any software, especially web apps. React is a JavaScript library for building user interfaces. React ships with several ways to minimize the number of costly DOM operations requir...]]></description><link>https://blog.reactplay.io/optimising-performance-of-a-react-application</link><guid isPermaLink="true">https://blog.reactplay.io/optimising-performance-of-a-react-application</guid><category><![CDATA[React]]></category><category><![CDATA[hooks]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[General Programming]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Bhavika Tibrewal]]></dc:creator><pubDate>Sat, 12 Nov 2022 03:36:52 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1668073611779/AT1H6mCuH.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Optimisation is the number one thing on every dev's mind when building any software, especially web apps. React is a JavaScript library for building user interfaces. React ships with several ways to minimize the number of costly DOM operations required to update the UI. Using React will lead to a fast user interface for many applications without doing much work to specifically optimise for performance. </p>
<p>When we create a rendered component, React creates a virtual DOM for its element tree in the component. Now, whenever the state of the component changes, React recreates the virtual DOM tree and compares the result with the previous render.</p>
<p>It then only updates the changed element in the actual DOM. This process is called diffing.</p>
<p>React uses the concept of a virtual DOM to minimize the performance cost of re-rendering a webpage because the actual DOM is expensive to manipulate.</p>
<p>The issue comes when the child components are not affected by the state change. In other words, they do not receive any prop from the parent component.</p>
<p>React nonetheless re-renders these child components. So, as long as the parent component re-renders, all of its child components re-render regardless of whether a prop passes to them or not; this is the default behavior of React.</p>
<h2 id="heading-profiling-the-react-app-to-understand-where-bottlenecks-are">Profiling the React app to understand where bottlenecks are</h2>
<p>React allows us to measure the performance of our apps using the Profiler in the React DevTools. There, we can gather performance information every time our application renders.</p>
<p>The profiler records how long it takes a component to render, why a component is rendering, and more. From there, we can investigate the affected component and provide the necessary optimization.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1651657618756/cXgYegqmt.png" alt="image.png" /></p>
<h2 id="heading-1-keeping-component-state-local-where-necessary">1. Keeping component state local where necessary</h2>
<pre><code><span class="hljs-keyword">import</span> { useState } <span class="hljs-keyword">from</span> <span class="hljs-string">"react"</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">App</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">const</span> [input, setInput] = useState(<span class="hljs-string">""</span>);

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
        <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span>
        <span class="hljs-attr">value</span>=<span class="hljs-string">{input}</span>
        <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setInput(e.target.value)}
      /&gt;
      <span class="hljs-tag">&lt;<span class="hljs-name">h3</span>&gt;</span>Input text: {input}<span class="hljs-tag">&lt;/<span class="hljs-name">h3</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">ChildComponent</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">ChildComponent</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"child component is rendering"</span>);
  <span class="hljs-keyword">return</span> <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>This is child component.<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>;
};
</code></pre><p>Whenever the state of the App component updates, the ChildComponent re-renders even when it is not directly affected by the state change.</p>
<p>To ensure re-rendering a component only happens when necessary, we can extract the part of the code that cares about the component state, making it local to that part of the code.</p>
<pre><code><span class="hljs-keyword">import</span> { useState } <span class="hljs-keyword">from</span> <span class="hljs-string">"react"</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">App</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">FormInput</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">ChildComponent</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
}
</code></pre><p>This ensures that only the component that cares about the state renders. In our code, only the input field cares about the state. So, we extracted that state and the input to a <code>FormInput</code> component, making it a sibling to the <code>ChildComponent</code>.</p>
<p>This means, that when the state changes, only the <code>FormInput</code> component re-renders, and the <code>ChildComponent</code> no longer re-renders on every keystroke. </p>
<h2 id="heading-2-react-lazy-for-lazy-loading-components">2. React. Lazy for Lazy Loading Components</h2>
<p>To implement code-splitting, we transform a normal React import like this:</p>
<pre><code><span class="hljs-keyword">import</span> Home <span class="hljs-keyword">from</span> <span class="hljs-string">"./components/Home"</span>;
<span class="hljs-keyword">import</span> About <span class="hljs-keyword">from</span> <span class="hljs-string">"./components/About"</span>;
</code></pre><p>And then into something like this:</p>
<pre><code><span class="hljs-keyword">const</span> Home = React.lazy(<span class="hljs-function">() =&gt;</span> <span class="hljs-keyword">import</span>(<span class="hljs-string">"./components/Home"</span>));
<span class="hljs-keyword">const</span> About = React.lazy(<span class="hljs-function">() =&gt;</span> <span class="hljs-keyword">import</span>(<span class="hljs-string">"./components/About"</span>));
</code></pre><p>This syntax tells React to load each component dynamically. So, when a user follows a link to the home page, for instance, React only downloads the file for the requested page instead of loading a large bundle file for the entire application.</p>
<p>After the import, we must render the lazy components inside a Suspense component like so:</p>
<pre><code>&lt;Suspense fallback={<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Loading page...<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span></span>}&gt;
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">Route</span> <span class="hljs-attr">path</span>=<span class="hljs-string">"/"</span> <span class="hljs-attr">exact</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">Home</span> /&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">Route</span>&gt;</span></span>
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">Route</span> <span class="hljs-attr">path</span>=<span class="hljs-string">"/about"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">About</span> /&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">Route</span>&gt;</span></span>
&lt;/Suspense&gt;
</code></pre><p>The Suspense allows us to display a loading text or indicator as a fallback while React waits to render the lazy component in the UI.</p>
<h2 id="heading-3-reactmemo">3. React.memo</h2>
<blockquote>
<p>In computing, memoization is an optimization technique used primarily to speed up computer programs by storing the results of expensive function calls and returning the cached result when the same inputs occur again.</p>
</blockquote>
<p>In essence, if a child component receives a prop, a memoized component shallowly compares the prop by default and skips re-rendering the child component if the prop hasn’t changed:</p>
<pre><code><span class="hljs-keyword">import</span> { useState } <span class="hljs-keyword">from</span> <span class="hljs-string">"react"</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">App</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">const</span> [input, setInput] = useState(<span class="hljs-string">""</span>);
  <span class="hljs-keyword">const</span> [count, setCount] = useState(<span class="hljs-number">0</span>);

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
        <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span>
        <span class="hljs-attr">value</span>=<span class="hljs-string">{input}</span>
        <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setInput(e.target.value)}
      /&gt;
      <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{()</span> =&gt;</span> setCount(count + 1)}&gt;Increment counter<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h3</span>&gt;</span>Input text: {input}<span class="hljs-tag">&lt;/<span class="hljs-name">h3</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h3</span>&gt;</span>Count: {count}<span class="hljs-tag">&lt;/<span class="hljs-name">h3</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">hr</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">ChildComponent</span> <span class="hljs-attr">count</span>=<span class="hljs-string">{count}</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">ChildComponent</span>(<span class="hljs-params">{ count }</span>) </span>{
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"child component is rendering"</span>);
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>This is a child component.<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h4</span>&gt;</span>Count: {count}<span class="hljs-tag">&lt;/<span class="hljs-name">h4</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
}
</code></pre><p>By updating the input field, both the App component and ChildComponent re-render.</p>
<p>Instead, the <code>ChildComponent</code> should only re-render when clicking the count button because it must update the UI. Here, we can <code>memoize</code> the <code>ChildComponent</code> to optimize our app’s performance.</p>
<p>React.memo is a higher-order component used to wrap a purely functional component to prevent re-rendering if the props received in that component never changes:</p>
<pre><code><span class="hljs-keyword">import</span> React, { useState } <span class="hljs-keyword">from</span> <span class="hljs-string">"react"</span>;

<span class="hljs-keyword">const</span> ChildComponent = React.memo(<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">ChildComponent</span>(<span class="hljs-params">{ count }</span>) </span>{
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"child component is rendering"</span>);
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>This is a child component.<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h4</span>&gt;</span>Count: {count}<span class="hljs-tag">&lt;/<span class="hljs-name">h4</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
});
</code></pre><p>If the count prop never changes, React will skip rendering the <code>ChildComponent</code> and reuse the previous rendered result. Hence improving React’s performance.</p>
<p><code>React.memo()</code> works pretty well when we pass down primitive values, such as a number in our example. And, if you are familiar with referential equality, primitive values are always referentially equal and return true if values never change.</p>
<p>On the other hand, non-primitive values like object, which include arrays and functions, always return false between re-renders because they point to different spaces in memory.</p>
<p>When we pass down an object, array, or function as a prop, the memoized component always re-renders. Here, we are passing down a function to the child component:</p>
<pre><code><span class="hljs-keyword">import</span> React, { useState } <span class="hljs-keyword">from</span> <span class="hljs-string">"react"</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">App</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-comment">// ...</span>

  <span class="hljs-keyword">const</span> incrementCount = <span class="hljs-function">() =&gt;</span> setCount(count + <span class="hljs-number">1</span>);

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      {/* ... */}
      <span class="hljs-tag">&lt;<span class="hljs-name">ChildComponent</span> <span class="hljs-attr">count</span>=<span class="hljs-string">{count}</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{incrementCount}</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
}

<span class="hljs-keyword">const</span> ChildComponent = React.memo(<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">ChildComponent</span>(<span class="hljs-params">{ count, onClick }</span>) </span>{
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"child component is rendering"</span>);
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      {/* ... */}
      <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{onClick}</span>&gt;</span>Increment<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
      {/* ... */}
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
});
</code></pre><p>This code focuses on the <code>incrementCount</code> function passing to the <code>ChildComponent</code>. When the App component re-renders, even when the count button is not clicked, the function redefines, making the <code>ChildComponent</code> also re-render.</p>
<p>To prevent the function from always redefining, we will use a <code>useCallback</code> Hook that returns a memoized version of the callback between renders.</p>
<h3 id="heading-using-the-usecallback-hook">Using the <code>useCallback</code> Hook</h3>
<p>With the <code>useCallback</code> Hook, the <code>incrementCount</code> function only redefines when the count dependency array changes:</p>
<pre><code><span class="hljs-keyword">const</span> incrementCount = React.useCallback(<span class="hljs-function">() =&gt;</span> setCount(count + <span class="hljs-number">1</span>), [count]);
</code></pre><h3 id="heading-using-the-usememo-hook">Using the <code>useMemo</code> Hook</h3>
<p>When the prop we pass down to a child component is an array or object, we can use a <code>useMemo</code> Hook to memoize the value between renders. As we’ve learned above, these values point to different spaces in memory and are entirely new values.</p>
<p>You can also use the <code>useMemo</code> Hook to avoid re-computing the same expensive value in a component. It allows us to <code>memoize</code> these values and only re-compute them if the dependencies change.</p>
<p>Similar to <code>useCallback</code>, the <code>useMemo</code> Hook also expects a function and an array of dependencies:</p>
<pre><code><span class="hljs-keyword">const</span> memoizedValue = React.useMemo(<span class="hljs-function">() =&gt;</span> {
  <span class="hljs-comment">// return expensive computation</span>
}, []);
</code></pre><p>Let’s see how to apply the useMemo Hook to improve a React app’s performance. Take a look at the following code that we’ve intentionally delayed to be very slow.</p>
<pre><code><span class="hljs-keyword">import</span> React, { useState } <span class="hljs-keyword">from</span> <span class="hljs-string">"react"</span>;

<span class="hljs-keyword">const</span> expensiveFunction = <span class="hljs-function">(<span class="hljs-params">count</span>) =&gt;</span> {
  <span class="hljs-comment">// artificial delay (expensive computation)</span>
  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>; i &lt; <span class="hljs-number">1000000000</span>; i++) {}
  <span class="hljs-keyword">return</span> count * <span class="hljs-number">3</span>;
};

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">App</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-comment">// ...</span>
  <span class="hljs-keyword">const</span> myCount = expensiveFunction(count);
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      {/* ... */}
      <span class="hljs-tag">&lt;<span class="hljs-name">h3</span>&gt;</span>Count x 3: {myCount}<span class="hljs-tag">&lt;/<span class="hljs-name">h3</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">hr</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">ChildComponent</span> <span class="hljs-attr">count</span>=<span class="hljs-string">{count}</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{incrementCount}</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
}

<span class="hljs-keyword">const</span> ChildComponent = React.memo(<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">ChildComponent</span>(<span class="hljs-params">{ count, onClick }</span>) </span>{
  <span class="hljs-comment">// ...</span>
});
</code></pre><p>Every time the App component renders, it invokes the <code>expensiveFunction</code> and slows down the app.</p>
<p>The <code>expensiveFunction</code> should only be called when the count button is clicked, not when we type in the input field. We can <code>memoize</code> the returned value of the <code>expensiveFunction</code> using the <code>useMemo</code> Hook so that it only re-computes the function only when needed, i.e., when the count button is clicked.</p>
<p>For that, we will have something like this:</p>
<pre><code><span class="hljs-keyword">const</span> myCount = React.useMemo(<span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">return</span> expensiveFunction(count);
}, [count]);
</code></pre><p>Optimization techniques come with a cost if not used properly and wrapping everything in <code>memo</code> or <code>useCallback</code> won't magically make your apps fast, but using them properly and profiling along the way could be a lifesaver.</p>
<h2 id="heading-4-windowing-or-list-virtualization-in-react-applications">4. Windowing or list virtualization in React applications</h2>
<p>When you want to render an enormous table or list of data, it can significantly slow down your app’s performance. Virtualization can help in a scenario like this with the help of a library like react-window. react-window helps solve this problem by rendering only the items in the list that are currently visible, which allows for efficiently rendering lists of any size.</p>
<h2 id="heading-5-lazy-loading-images-in-react">5. Lazy loading images in React</h2>
<p>To optimize an application that consists of several images, we can avoid rendering all of the images at once to improve the page load time. With lazy loading, we can wait until each of the images is about to appear in the viewport before we render them in the DOM.  </p>
<h2 id="heading-conclusion">Conclusion:</h2>
<p>To optimize our React application, we must first find a performance problem in our application to rectify. In this guide, we’ve explained how to measure the performance of a React application and how to optimize the performance for a better user experience.</p>
<p>If you find these techniques helpful do share them with others and also I would love to know of any other techniques, so do comment down below</p>
]]></content:encoded></item><item><title><![CDATA[How to get started with GitHub Actions]]></title><description><![CDATA[You are probably familiar with Github. A platform to build software, collaborate with folks and contribute to open-source projects.
GitHub provides many functionalities that make your life easier as a developer.
In this blog, we are going to learn ab...]]></description><link>https://blog.reactplay.io/how-to-get-started-with-github-actions</link><guid isPermaLink="true">https://blog.reactplay.io/how-to-get-started-with-github-actions</guid><category><![CDATA[github-actions]]></category><category><![CDATA[opensource]]></category><category><![CDATA[beginnersguide]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[General Programming]]></category><dc:creator><![CDATA[Shivam Katare]]></dc:creator><pubDate>Fri, 11 Nov 2022 04:00:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1667991410675/GfupdsMfD.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>You are probably familiar with Github. A platform to build software, collaborate with folks and contribute to open-source projects.</p>
<p>GitHub provides many functionalities that make your life easier as a developer.</p>
<p>In this blog, we are going to learn about <strong><a target="_blank" href="https://docs.github.com/en/actions">GitHub Actions</a></strong> by using a simple example. This blog will help you to understand and get the basic idea of <strong>GitHub Actions.</strong> So, without wasting a bit. Let's start.</p>
<h1 id="heading-what-are-github-actions">What are GitHub Actions?</h1>
<p>In simple words, <strong><a target="_blank" href="https://docs.github.com/en/actions">GitHub Actions</a></strong> help us to do things automatically when any event occurs.</p>
<h3 id="heading-definition">Definition</h3>
<p>GitHub Actions is a platform for automating software development, testing, and deployment. It allows us to run arbitrary code on our repository when a specific event happens.</p>
<blockquote>
<p>So, with the help of <strong>GitHub Actions,</strong> you can write some code that will run whenever a particular event occurs. <strong>Events</strong> can be a PR, any issue, any push commit, and so on.</p>
</blockquote>
<ul>
<li>GitHub Actions contains several components that help us to understand GitHub Actions more simply. </li>
</ul>
<h3 id="heading-github-actions-components">GitHub Actions Components</h3>
<p><strong>1️⃣ Event</strong></p>
<p>An event is anything that can happen on a GitHub repository. It goes from pushing a code, creating a branch, opening a pull request, and even commenting on an issue.
The list of triggers is much longer: you can check it out <a target="_blank" href="https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#webhook-events">here</a>. </p>
<p><strong>2️⃣  Workflows</strong></p>
<p>A workflow is a configurable automated process that runs one or more jobs.</p>
<p>Workflows are defined in YAML files and kept in the repository root directory in the .github/workflows directory. A repository can also have multiple workflows.</p>
<p><strong>3️⃣ Jobs</strong></p>
<p>A job is a collection of tasks executed in a workflow when triggered by an event. Each step is either a script or a Github action. A workflow can have multiple jobs that run in parallel.</p>
<p><strong>4️⃣ Runners</strong></p>
<p>Runners are processed on a server and run the workflow when triggered. Each runner is responsible for executing a given job.
Runners are hosted in the cloud but can also be self-hosted in custom cloud environments.</p>
<p><strong>5️⃣ Actions</strong></p>
<p>Actions are individual tasks: they are called inside a job. Actions used to perform complex tasks that you may call multiple times and import into your workflows. 
You can build your actions or reuse some open-source actions from the GitHub marketplace and add them to your workflow directly when they meet your needs.</p>
<p>In this image, you can see the working of GitHub actions. You'll understand more once you see it with an example.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667889638363/kmwpZ4fBK.png" alt="image.png" /></p>
<h1 id="heading-github-actions-example">GitHub Actions Example</h1>
<p>Now we will see a quick example of GitHub actions. This example will be short but will help you in grasping GitHub actions.</p>
<p>Go to your GitHub and create a new repository. Click on this <strong><code>new</code></strong> button to create a new repo.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667890555972/8yd0NASm7.png" alt="1667790098061.png" /></p>
<p>Enter the name of your repository. I named <strong>github-actions-example.</strong>👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667933036355/8LOiJKX6r.png" alt="Blue Red and Yellow typhography Welcome To Graphic Design Facebook Cover (1600 × 840 px) (1600 × 840 px) (1600 × 840 px) (2).png" /></p>
<p>Now choose the visibility 👆 of your repo. I will pick private because it's just an example. You can pick as per your choice.</p>
<p>Click on the <code>button</code>👇. Your repo is created. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667933208166/w8-R58fb4.png" alt="Blue Red and Yellow typhography Welcome To Graphic Design Facebook Cover (1600 × 840 px) (1600 × 840 px) (1600 × 840 px) (3).png" /></p>
<blockquote>
<p><strong>Note -</strong> I'm doing everything in the same place (in the browser) to help you understand it better. You can follow the same process with any code editor if you want.</p>
</blockquote>
<p>Click on <strong><code>create a new file.</code></strong> 👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667933392305/OUFeZbeWN.png" alt="Blue Red and Yellow typhography Welcome To Graphic Design Facebook Cover (1600 × 840 px) (1600 × 840 px) (1600 × 840 px) (4).png" /></p>
<p>Enter your file name. I am using a <strong><code>JS</code></strong> file. You can make it as per your choice.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667933507767/BBooBDbog.png" alt="Blue Red and Yellow typhography Welcome To Graphic Design Facebook Cover (1600 × 840 px) (1600 × 840 px) (1600 × 840 px) (5).png" /></p>
<p>Start writing content in this file. I am writing this, 👇 you can write any program.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667933593273/4AepJyhvo.png" alt="Blue Red and Yellow typhography Welcome To Graphic Design Facebook Cover (1600 × 840 px) (1600 × 840 px) (1600 × 840 px) (6).png" /></p>
<p>Now scroll down a bit and click on the <strong><code>the commit button.</code></strong> You can also write your commit message here.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667933806087/LfXUo83JC.png" alt="Blue Red and Yellow typhography Welcome To Graphic Design Facebook Cover (1600 × 840 px) (1600 × 840 px) (1600 × 840 px) (7).png" /></p>
<p>File created. 👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667933904877/sGXxUkorN.png" alt="Blue Red and Yellow typhography Welcome To Graphic Design Facebook Cover (1600 × 840 px) (1600 × 840 px) (1600 × 840 px) (8).png" /></p>
<p><strong>Adding GH Actions</strong></p>
<p>Now we will add the github actions to our repo.</p>
<blockquote>
<p><strong>Note</strong>- Github Actions should be in a specific folder. </p>
</blockquote>
<p>Click on the <strong><code>Add File</code> </strong> button and create a new file.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667934090126/cQIN6JeQh.png" alt="Screenshot (275).png" /></p>
<p>Please enter the folder name(be sure to use the same name). I named <strong><code>.github</code></strong> (press the forward slash to enter into this folder) and create a new folder <strong> <code>workflows.</code></strong> Into this folder, enter the name of your file(you can write any name here). This file should be a <strong><em>yaml</em></strong>. I named it <strong><code>build.yml</code></strong> 👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667934236252/qDVUMzfez.png" alt="Blue Red and Yellow typhography Welcome To Graphic Design Facebook Cover (1600 × 840 px) (1600 × 840 px) (1600 × 840 px) (10).png" /></p>
<p>In this file, we will be writing out github actions.</p>
<p>So, we will start with the name. This is the name of your github action.</p>
<pre><code>name: build
</code></pre><p>Now we will add <strong>trigger</strong>. The triggers can be a push, a pull, etc.</p>
<pre><code>name: Build
<span class="hljs-attr">on</span>: [push]
</code></pre><p>Here we are using push. As a result, whenever someone pushes code to this repo, the github action is triggered.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667917449783/x1aYZqK7w.png" alt="Screenshot (280).png" /></p>
<p>The next part is to define <strong>Jobs</strong>(we have learned about jobs above). </p>
<pre><code>name: Build
<span class="hljs-attr">on</span>: [push]

<span class="hljs-attr">jobs</span>: 
  build:    <span class="hljs-comment">//this is the name of the job. You can give any name</span>
    runs-on: windows-latest  <span class="hljs-comment">// enter your machine name. If you're using Ubuntu, write ubuntu-latest. I am using windows.</span>
</code></pre><p>In this job, we will have steps, and you can define multiple steps inside this job. Each step is either a script or a Github action.</p>
<ul>
<li>So, the first thing we want to do is check out the code so we can use it in a built-in GitHub action where we say,  check out, and we're going to use version three(you can also use v2). 👇</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667919180195/TaF-ZtyBm.png" alt="Screenshot (281).png" /></p>
<p>Next, we'll determine whether the code being pushed contains the node environment or not. So, for this, we will set up a node like this 👇</p>
<pre><code>...

jobs: 
  build: 
    runs-on: windows-latest
    <span class="hljs-attr">steps</span>: 
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667919483866/V6jZad892.png" alt="Screenshot (282).png" /></p>
<blockquote>
<p>There are many versions of node, and everyone uses different versions. So, how will we specify which node version will correct for this repo? So, for this, we can use <strong>Variables</strong> inside steps. </p>
</blockquote>
<p>To use <strong>variables,</strong> you can write like this 👇</p>
<pre><code>...

steps: 
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        <span class="hljs-attr">with</span>: 
         node-version: <span class="hljs-string">'16'</span>
</code></pre><p>Here 👆 you can see that I used <strong><code>node version: 16</code>.</strong> It means that whenever someone pushes a code to this repo, it should contain a node with version 16. If the code does not include version 16, The run fails, or if it is, the job succeeds.</p>
<blockquote>
<p>You can choose any version 16, 15, 14, etc.</p>
</blockquote>
<p>Your code should now look like this.👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667931030094/RCLzJt8oW.png" alt="Screenshot (284).png" /></p>
<p>The next step is to execute the command to execute the code in our <code>index.js</code> file. The run command can be an <code>npm ci</code> or <code>npm install</code> step, but in this case, we'll use 'node' to call our <code>'index.js'</code> file.
The next step is to execute the command that will execute our code. 👇</p>
<pre><code>...

steps: 
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        <span class="hljs-attr">with</span>: 
         node-version: <span class="hljs-string">'16'</span>
      - run: node index.js
</code></pre><p>Here 👆 you can see that I use the <code>run</code> then, with the help of the <code>node</code> command, I'll call our <code>index.js</code> file.</p>
<p>Now our whole code will look like this. 👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667931298972/82BeIw0vr.png" alt="Screenshot (283).png" /></p>
<p>And that's it. You can see that you may repeat the processes within the job or have another job. So, once this job is complete, run the following one.</p>
<ul>
<li>For now, we will commit this file. You can enter your commit message and click on the commit button.👇</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667931513497/1jJ-ehYA2.png" alt="Screenshot (285).png" /></p>
<p>After you've committed your file, go to the '<strong><code>code</code></strong>' tab and look for the <strong><em> <code>orange circle</code> </em></strong>. It means your github actions are working. 👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667931725199/nJO8k6qsC.png" alt="Screenshot (286).png" /></p>
<p>Whenever you or someone pushes any code, the github action will run.</p>
<p>You can also check this by clicking on this <strong><code>Action</code></strong> tab. Here you can see your success and failure runs of actions. By clicking on this successful one,👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667931943451/7j7umbgTL.png" alt="Screenshot (287).png" /></p>
<p>and then, this 👇 build file,</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667932054311/S_4nl0vl0.png" alt="Screenshot (288).png" /></p>
<p>You can see all your different steps.👇 </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667932113085/P0LmAZvCn.png" alt="Screenshot (289).png" /></p>
<p>You can also explore them by clicking on each stage. If you click on this <code>'run node,'</code> you can view the contents of our <code>'index.js'</code> file.👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667932281923/_ummfdYnh.png" alt="Screenshot (291).png" /></p>
<h1 id="heading-wrapping-up">Wrapping Up</h1>
<p>That's all for now; hopefully, you now understand the fundamentals of Github Actions. I hope this article clarifies things.</p>
<p>If you learn something from it, share it with your friends and like this blog.</p>
<p><strong><a target="_blank" href="https://youtu.be/-ZiuJdT1i0k">Reference</a></strong></p>
<h2 id="heading-you-can-join-my-learnings">You can join my learnings</h2>
<ul>
<li><p><a target="_blank" href="https://github.com/Shivam-Katare">GitHub</a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/Shivamkatare_27">Twitter</a></p>
</li>
<li><p><a target="_blank" href="https://www.linkedin.com/in/shivam-katare-aa80b218b/">LinkedIn</a></p>
</li>
<li><p><a target="_blank" href="https://www.showwcase.com/shivam-katare">ShowwCase</a></p>
</li>
</ul>
]]></content:encoded></item></channel></rss>