<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jitendra Choudhary</title>
    <description>The latest articles on DEV Community by Jitendra Choudhary (@jitendrachoudhary).</description>
    <link>https://dev.to/jitendrachoudhary</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1269427%2Fff38e060-9faa-46bf-b985-bb9292de5c08.jpeg</url>
      <title>DEV Community: Jitendra Choudhary</title>
      <link>https://dev.to/jitendrachoudhary</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jitendrachoudhary"/>
    <language>en</language>
    <item>
      <title>Every React Concept Explained in 5 Minutes</title>
      <dc:creator>Jitendra Choudhary</dc:creator>
      <pubDate>Tue, 28 Jan 2025 09:15:34 +0000</pubDate>
      <link>https://dev.to/jitendrachoudhary/every-react-concept-explained-in-5-minutes-48bd</link>
      <guid>https://dev.to/jitendrachoudhary/every-react-concept-explained-in-5-minutes-48bd</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/jitendrachoudhary" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1269427%2Fff38e060-9faa-46bf-b985-bb9292de5c08.jpeg" alt="jitendrachoudhary"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/jitendrachoudhary/every-react-concept-explained-in-5-minutes-39b9" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Every React Concept Explained in 5 Minutes&lt;/h2&gt;
      &lt;h3&gt;Jitendra Choudhary ・ Jul 29 '24&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#react&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#webdev&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#codenewbie&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Integrating Stellar with JavaScript: Building dApp is easy</title>
      <dc:creator>Jitendra Choudhary</dc:creator>
      <pubDate>Wed, 14 Aug 2024 07:12:16 +0000</pubDate>
      <link>https://dev.to/jitendrachoudhary/integrating-stellar-with-javascript-building-dapp-is-easy-4pg2</link>
      <guid>https://dev.to/jitendrachoudhary/integrating-stellar-with-javascript-building-dapp-is-easy-4pg2</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/stellar"&gt;Build Better on Stellar: Smart Contract Challenge &lt;/a&gt;: Create a Tutorial&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Your Tutorial
&lt;/h2&gt;

&lt;p&gt;This is the link to my tutorial:-&lt;br&gt;
&lt;a href="https://dev.to/jitendrachoudhary/integrating-stellar-with-javascript-building-dapp-is-easy-for-absolute-beginners-4n66"&gt;Integrating Stellar with JavaScript: Building dApp is easy (for absolute beginner)&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;I created a tutorial on how to integrate Stellar with JavaScript. I started with the basic explanation of the Stellar ecosystem. Along this, I dive into topics like Testnet, Lumens, and more as they come into the process.&lt;/p&gt;

&lt;p&gt;This tutorial is meant for JavaScript developers who want to build DApp, this tutorial serves as a starting for them.&lt;/p&gt;

&lt;p&gt;By using this tutorial one can conveniently integrate Stellar with JavaScript and start building DApps.   &lt;/p&gt;

&lt;h2&gt;
  
  
  Journey
&lt;/h2&gt;

&lt;p&gt;I mainly used Stellar's documentation as a reference. I also read some articles on the blockchain ecosystem and how it works.&lt;/p&gt;

&lt;p&gt;The motivation for this submission was that I am a JavaScript developer, and not far ago, just 10 months ago, I wanted to build a social media messaging DApp. The DApp will keep the data safe and will not promote any falsely funded content, so the users would not have to worry about infiltration into the system. Learning a new skill is not easy, and having a steeper curve, it was very hard to learn blockchain. However, with Stellar's Soroban, it is even easy to write smart contracts.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>stellarchallenge</category>
      <category>blockchain</category>
      <category>web3</category>
    </item>
    <item>
      <title>Integrating Stellar with JavaScript: Building dApp is Easy (for Absolute Beginners)</title>
      <dc:creator>Jitendra Choudhary</dc:creator>
      <pubDate>Tue, 13 Aug 2024 16:06:35 +0000</pubDate>
      <link>https://dev.to/jitendrachoudhary/integrating-stellar-with-javascript-building-dapp-is-easy-for-absolute-beginners-4n66</link>
      <guid>https://dev.to/jitendrachoudhary/integrating-stellar-with-javascript-building-dapp-is-easy-for-absolute-beginners-4n66</guid>
      <description>&lt;p&gt;Stellar is an open-source blockchain network for fast and cross-border financial transactions. If you are a JavaScript developer and wanna build dApp on a stellar network, this is the thing for you. In this tutorial, we will learn how to integrate Stellar with JavaScript, from setting up the environment to making your first transaction.&lt;/p&gt;

&lt;p&gt;So, let's start.&lt;/p&gt;

&lt;p&gt;Oh, before we begin, we need basic knowledge of JavaScript and have npm and Node.js installed on your machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Sitting Up the Environment
&lt;/h2&gt;

&lt;p&gt;First, open your terminal or command prompt and create a new directory for the project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;stellar-js
&lt;span class="nb"&gt;cd &lt;/span&gt;stellar-js
npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will initialize a new Node.js project.&lt;/p&gt;

&lt;p&gt;Now, install the Stellar SDK for JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;stellar-sdk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But, wait &lt;strong&gt;What is Stellar-SDK?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Stellar SDK is a powerful library to interact with the Stellar network using JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Connecting to the Stellar Network
&lt;/h2&gt;

&lt;p&gt;Now, that the environment is set up, we will connect with the Stellar network. We require Stellar SDK and connect to the testnet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What's Testnet?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Testnet is a free-to-use network for a developer to test their application without connecting to real money. Where there is a mainnet that connects to real money and requires XLM to cover transaction fees, etc. The testnet is similar to the mainnet, it has free test Lumens (XLM) called Friendbot.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;StellarSdk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;stellar-sdk&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;StellarSdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Server&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://horizon-testnet.stellar.org&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will initialize the SDK and set the server to connect to the testnet.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Creating a New Account
&lt;/h2&gt;

&lt;p&gt;To interact with the Stellar network, you need to have a Stellar account. You can easily create a new account using SDK by generating a key-value pair. The value pair consists of a public and a private key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;const pair &lt;span class="o"&gt;=&lt;/span&gt; StellarSdk.Keypair.random&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

console.log&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Public Key:'&lt;/span&gt;, pair.publicKey&lt;span class="o"&gt;())&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
console.log&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Secret Key:'&lt;/span&gt;, pair.secret&lt;span class="o"&gt;())&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;publicKey()&lt;/code&gt; is your account’s identifier, while the &lt;code&gt;secret()&lt;/code&gt; is your private key, which should be kept secure.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Funding the Account
&lt;/h2&gt;

&lt;p&gt;In the testnet, you can fund your account using Stellar's Friendbot service.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fetch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;node-fetch&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fundAccount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;publicKey&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="s2"&gt;`https://friendbot.stellar.org?addr=&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;publicKey&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Account funded:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Error funding account:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nf"&gt;fundAccount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pair&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;publicKey&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;fundAccount&lt;/code&gt; function sends a request to Friendbot to deposit 10k test Lumens in your account. Accordingly, to the status of the transaction, it will log the message.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Making a Transaction
&lt;/h2&gt;

&lt;p&gt;Now, that your account is founded, you can make your first transaction on the stellar network. We'll build, sign, and submit the transaction to the stellar network. We'll send 10 XLM from our account to another account.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sendPayment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;publicKey&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;account&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;loadAccount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pair&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;publicKey&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;transaction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;StellarSdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;TransactionBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;account&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;fee&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;StellarSdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;BASE_FEE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;networkPassphrase&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;StellarSdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Networks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;TESTNET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addOperation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nx"&gt;StellarSdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Operation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;payment&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
          &lt;span class="na"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;publicKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;asset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;StellarSdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Asset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;native&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
          &lt;span class="na"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;10&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;})&lt;/span&gt;
      &lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="nx"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pair&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;submitTransaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Transaction successful:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Error sending payment:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nf"&gt;sendPayment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Another_Account's_Public_Key&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. Error Handling and Debugging
&lt;/h2&gt;

&lt;p&gt;Even a single comma ( , ) can ruin your code. Handling errors is very important to keep the code on the expected track.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;submitTransaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Success:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Error:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;extras&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;result_codes&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This catches any errors during the transaction and logs the specific error which helps to debug the code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We just integrated Stellar with JavaScript and made our first transaction on the Stellar testnet. As JavaScript is widely adopted among developers, transitioning to the blockchain with Stellar is more convenient.&lt;/p&gt;

&lt;p&gt;The best way to learn any new skill is to practice more projects. Build small projects and experiment with the concepts.&lt;/p&gt;

&lt;p&gt;If you find this post helpful don't forget to keep showing me love. Until next time like, share, and learn.&lt;/p&gt;

&lt;p&gt;You can also stay connected with me by following me here and on &lt;a href="https://x.com/jiitendraC" rel="noopener noreferrer"&gt;X&lt;/a&gt;, &lt;a href="https://github.com/J11tendra/" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;, and &lt;a href="https://www.linkedin.com/in/jiitendrachoudhary/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>blockchain</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Every React Concept Explained in 5 Minutes</title>
      <dc:creator>Jitendra Choudhary</dc:creator>
      <pubDate>Mon, 29 Jul 2024 12:33:00 +0000</pubDate>
      <link>https://dev.to/jitendrachoudhary/every-react-concept-explained-in-5-minutes-39b9</link>
      <guid>https://dev.to/jitendrachoudhary/every-react-concept-explained-in-5-minutes-39b9</guid>
      <description>&lt;p&gt;React is a JavaScript library that allows you to develop front-end code in minutes. It has pre-built methods and functions to perform certain tasks. React as a library includes complex terms like reconciliation, state, props, etc. What do they actually mean?&lt;/p&gt;

&lt;p&gt;In this article, you will learn about this exaggerated concept more simply.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. &lt;strong&gt;Components&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Components are small bit of reusable code that return a React element to be rendered on a webpage. It is a group of code that make up a single part of the webpage like buttons, navbar, cards, etc. It is just like a JavaScript function but returns a rendered element. It accepts parameters called &lt;strong&gt;"Props"&lt;/strong&gt;. Components are named with capital case.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example Of Functional Component&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Heading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Join&lt;/span&gt; &lt;span class="nx"&gt;us&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;!&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Functional Components are recommended instead of Class based.&lt;/li&gt; &lt;li&gt;Functional components are often called statefull components when the UI is updated dynamically due to state's value not Prop's value.&lt;/li&gt;
&lt;li&gt;Functional components are called stateless components when it uses Prop's value to dynamically change UI not state's value.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. &lt;strong&gt;JSX&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;JSX is JavaScript XML, which allows us to write HTML in React. It introduces XML-like tags and attributes to create React elements. It makes it easy to create React Components by letting you write HTML-like code in &lt;code&gt;.jsx&lt;/code&gt; files. Instead of using complicated JavaScript, JSX makes the code readable and clean. React DOM uses camelCase for attribute naming such as &lt;code&gt;htmlFor, onClick&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of JSX&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;head&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;This&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;H1&lt;/span&gt;&lt;span class="o"&gt;!&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, TSX is a file extension for TypeScript files that contains JSX syntax. With TSX you can write type-checked code with the existing JSX syntax. TypeScript is not a different language, it is just a superset of JavaScript that adds optional static typing.&lt;/p&gt;

&lt;p&gt;More simply, with TSX files you can write React components using TypeScript and JSX together.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of TSX&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;AgeProps&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;GreetAge&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;AgeProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nx"&gt;Hello&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;you&lt;/span&gt; &lt;span class="nx"&gt;are&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;old&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JSX files uses a `.jsx` file extension.&lt;/li&gt;
&lt;li&gt;TSX files uses a `.tsx` file extension.&lt;/li&gt;
&lt;li&gt;TypeScript's type system helps catch potential errors early in development.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. &lt;strong&gt;Fragments&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Fragments in React allows you to return multiple elements from a component. It groups the list of elements without creating a extra DOM nodes. It cleans all the extra divs from the DOM. This quickly renders the UI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of Fragments&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return  &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Eat&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Learn&lt;/span&gt; &lt;span class="nx"&gt;more&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Code&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;Fun&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Repeat&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fragments makes the code cleaner and readable.&lt;/li&gt; &lt;li&gt;It are memory efficient.&lt;/li&gt;
&lt;li&gt;It cannot have CSS styles.&lt;/li&gt; 
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. &lt;strong&gt;Props&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;"Props" is a special keyword in React that stands for properties. It is used to transfer data between components. The follow of data transfer is uni-directional i.e from parent component to child component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of Props&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Head&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: Props is read-only, which ensures that child components don't manipulate the value coming from parent component.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. &lt;strong&gt;State&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Components need to keep track of certain values when user interacts. Let's say the light/dark mode theme toggle button changes its value(from light to dark &amp;amp; vice versa) when a user clicks on the button. Components need to remember the current value of theme. In React, this kind of component-specific memory is called state.&lt;/p&gt;

&lt;p&gt;State is defined using a &lt;code&gt;useState()&lt;/code&gt; hook; more on that later.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of defining state&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setIndex&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: It's always a good practice to define state in a top-level component to share it easily with other child components and ensure a single source of truth.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. &lt;strong&gt;Lifecycle Methods&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Lifecycle methods are special functions you can use within React classes to perform actions at various stages of a component's existence. These stages are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mounting: When a component is first created and inserted into the DOM.&lt;/li&gt;
&lt;li&gt;Updating: When a component's props or state change, causing the component to re-render.&lt;/li&gt;
&lt;li&gt;Unmounting: When a component is removed from the DOM.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  7. &lt;strong&gt;Purity&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Purity in functional programming is when a given same input returns the same output. The inputs is the only factor that determine the output then the function is said to be pure.&lt;/p&gt;

&lt;p&gt;In React a component is said to be pure when it returns the same output for the same input (viz props)&lt;/p&gt;

&lt;h2&gt;
  
  
  8. &lt;strong&gt;Strict Mode&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Strict Mode is a developmental feature in react that enables extra safety features to improve code quality. It shows warnings regarding potential errors and bugs into the code. It logs warning into the browser's console.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of Strict Mode&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

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

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;StrictMode&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Header&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Sidebar&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Content&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Footer&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/StrictMode&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzp1s993noitok8iwxby3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzp1s993noitok8iwxby3.png" alt="Strict Mode in React Showing Browser Console" width="800" height="452"&gt;&lt;/a&gt;&lt;/p&gt;
Strict Mode in React Showing Browser Console




&lt;h2&gt;
  
  
  9. &lt;strong&gt;Hooks&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Hooks in React allows to use state and other React features without writing class components. Hooks are functions that provide access to React's state management, side effects, and other features.&lt;/p&gt;

&lt;p&gt;Some commonly used hooks: &lt;code&gt;useState&lt;/code&gt;, &lt;code&gt;useMemo&lt;/code&gt;, &lt;code&gt;useRef&lt;/code&gt;, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of Hooks&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Importing useState hook;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;FavoriteColor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setColor&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;red&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Initializing the state and setter function;&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;My&lt;/span&gt; &lt;span class="nx"&gt;favorite&lt;/span&gt; &lt;span class="nx"&gt;color&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;!&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;
        &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setColor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;blue&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt; &lt;span class="c1"&gt;// Updating the state;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Blue&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;
        &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setColor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;red&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt; &lt;span class="c1"&gt;// Updating the state;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Red&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;
        &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setColor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;yellow&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt; &lt;span class="c1"&gt;// Updating the state;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Yellow&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hooks can only be called inside React function components.&lt;/li&gt;
&lt;li&gt;Hooks can only be called at the top level of a component.&lt;/li&gt;
&lt;li&gt;Hooks cannot be conditional.&lt;/li&gt;
  &lt;/ul&gt;

&lt;h2&gt;
  
  
  10. &lt;strong&gt;Context API&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The Context API is used to share data like state, functions across the component tree without passing props down manually at every level. It avoids &lt;em&gt;prop drilling&lt;/em&gt; by simplifying state management and sharing data across the component. With Context API the data is shared directly with the child component who will consume it.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;createContext()&lt;/code&gt; method is used to create a context. This function returns a context object with two components – a &lt;code&gt;Provider&lt;/code&gt; and a &lt;code&gt;Consumer&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;Provider&lt;/code&gt; is used to wrap the part of your component tree where you want the context to be available. It accepts a compulsory value prop that holds the data you want to share across other components.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;useContext&lt;/code&gt; hook is used to access the data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of Context API&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a context using &lt;code&gt;createContext()&lt;/code&gt; method. Wrap child components in the Context Provider and supply the state value.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;createContext&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;UserContext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createContext&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ParentCounter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;UserContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Provider&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;`Current Count: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;!`&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Button&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/UserContext.Provider&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Use &lt;code&gt;useContext&lt;/code&gt; hook to access the value of age.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useContext&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;GrandChildConsumer&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;UserContext&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;This&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;GrandChildConsumer&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;`Current Count: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h2&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


Note: The `useContext` hook is often used instead of Consumer for better readability and simplicity.

&lt;h2&gt;
  
  
  11. &lt;strong&gt;Lists and Keys&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;A &lt;code&gt;Key&lt;/code&gt; is a special kind of attribute for list items in React. It acts as a unique identifier for each items when it is updated, deleted, or added.&lt;/p&gt;

&lt;p&gt;Assigning index of the item as the &lt;code&gt;Key&lt;/code&gt; is discouraged because if the items are rearranged it will affect the expected behavior.&lt;/p&gt;

&lt;p&gt;Imagine in shopping cart you have 10 items added and each item have a unique index as a &lt;code&gt;Key&lt;/code&gt;. Now, you decide to remove the first and fifth item from the cart. When the items are removed the indexing will change; the second item will become first and sixth item will become fifth item.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of Lists and Keys&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fruits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apple&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;banana&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;orange&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;FruitList&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ul&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;fruit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;li&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;fruit&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/li&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="p"&gt;))}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/ul&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;


Note:
&lt;ul&gt;
&lt;li&gt;It is recommended to use string as a `Key` that uniquely identifies the item in the list.&lt;/li&gt; &lt;li&gt;Third-party libraries like UUID offer the functionality to create unique keys.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  12. &lt;strong&gt;Form: Controlled &amp;amp; Uncontrolled Components&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;React forms allows to collect and manage user input better than traditional HTML form. These forms are built using components and store the user inputs into state. There are two types of components:&lt;/p&gt;

&lt;h3&gt;
  
  
  Controlled Components
&lt;/h3&gt;

&lt;p&gt;In Controlled components, the form's state is managed by the component himself. This is the recommended approach for managing form data in React. When the user interacts with the form (e.g., typing in an input field), the component's state is updated to reflect the changes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of Controlled Component&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ControlledInput&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setName&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleChange&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;setName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleChange&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Your&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Uncontrolled Components
&lt;/h3&gt;

&lt;p&gt;Uncontrolled components rely on the DOM to manage the form data. The component doesn't directly control the form's state, but it can access the values using DOM methods like ref.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of Uncontrolled Component&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;UncontrolledInput&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;nameRef&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useRef&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleClick&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;nameRef&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;nameRef&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleClick&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Get&lt;/span&gt; &lt;span class="nx"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Controlled components provides form validation because the user's input is instantly reflected due to use of state.&lt;/li&gt; &lt;li&gt;Form validation is not possible in uncontrolled components because the user's input can only be accessed after the form is submitted.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  13. &lt;strong&gt;React Router&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduction to React Router for navigation&lt;/li&gt;
&lt;li&gt;Basic setup and usage&lt;/li&gt;
&lt;li&gt;Example: Creating routes and navigating between pages&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;React Router is a standard library for routing in React. It enables navigation among various components in the React app. It allows changing the browser URL and syncing the UI with the URL. React Router is important for creating single-page applications (SPA) with navigation features.&lt;/p&gt;

&lt;p&gt;First, you need to install React Router from your terminal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installing React Router&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# If you are using npm&lt;/span&gt;
npm &lt;span class="nb"&gt;install &lt;/span&gt;react-router-dom

&lt;span class="c"&gt;# If you are using yarn&lt;/span&gt;
yarn add react-router-dom
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example of React Router&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;BrowserRouter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Routes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-router-dom&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Home&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./pages/Home&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;About&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./pages/About&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Contact&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./pages/Contact&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;NoPage&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./pages/NoPage&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;BrowserRouter&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Routes&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Home&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;about&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;About&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;contact&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Contact&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;*&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;NoPage&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Routes&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/BrowserRouter&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First wrap your content into the &lt;code&gt;&amp;lt;BrowserRouter&amp;gt;&lt;/code&gt;. Then we define &lt;code&gt;&amp;lt;Routes&amp;gt;&lt;/code&gt; and inside that introduces the &lt;code&gt;&amp;lt;Route&amp;gt;&lt;/code&gt; for navigation. &lt;code&gt;&amp;lt;Route&amp;gt;&lt;/code&gt; has &lt;code&gt;path&lt;/code&gt; which specifies URL of the page and &lt;code&gt;element&lt;/code&gt; attribute which specifies the component that needs to be rendered on the defined path.&lt;/p&gt;

&lt;p&gt;Note:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An app can have multiple &amp;lt; Routes &amp;gt;.&lt;/li&gt; &lt;li&gt;&amp;lt; Route &amp;gt; can be nested.&lt;/li&gt;
&lt;li&gt;`react-router-dom` also has &amp;lt; Link &amp;gt; and &amp;lt; Outlet &amp;gt; Component for navigation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The best way to learn any programming language is to practice more projects. Build small projects and experiment with the concepts.&lt;/p&gt;

&lt;p&gt;If you find this post helpful don't forget to keep showing me love. Until next time like, share, and learn.&lt;/p&gt;

&lt;p&gt;You can also stay connected with me by following me here and on &lt;a href="https://twitter.com/JiitendraC" rel="noopener noreferrer"&gt;X&lt;/a&gt;, &lt;a href="https://github.com/J11tendra/" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;, and &lt;a href="https://www.linkedin.com/in/jiitendrachoudhary/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Learn CSS Positions: with Real Examples</title>
      <dc:creator>Jitendra Choudhary</dc:creator>
      <pubDate>Thu, 27 Jun 2024 10:41:11 +0000</pubDate>
      <link>https://dev.to/jitendrachoudhary/learn-css-positions-with-real-examples-4kbd</link>
      <guid>https://dev.to/jitendrachoudhary/learn-css-positions-with-real-examples-4kbd</guid>
      <description>&lt;p&gt;Let's start with even do you need CSS positions aren't the other properties enough to make you faint? Why CSS positions?&lt;/p&gt;

&lt;p&gt;Say you want to create an navigation bar which stays on the page when you scroll, or the chat with us icon/button that stays on the bottom right corner always. This things are placed outside of the document's (i.e the webpage) workflow.&lt;/p&gt;

&lt;p&gt;For examples, You see below the chat button or the navigation bar is still visible even after scrolling.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxsgvl06alsiuyhy7er2l.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxsgvl06alsiuyhy7er2l.gif" alt="CSS Position" width="400" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To build elements having similar behavior we use &lt;code&gt;CSS position&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;CSS position&lt;/code&gt; property is used to define the position of an element on a webpage.&lt;/p&gt;

&lt;p&gt;The position property has the following five values:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;static (default value)&lt;/li&gt;
&lt;li&gt;relative&lt;/li&gt;
&lt;li&gt;absolute&lt;/li&gt;
&lt;li&gt;fixed&lt;/li&gt;
&lt;li&gt;sticky&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will look into each of them.&lt;/p&gt;

&lt;p&gt;Before we begin lets first understand the basic context; we have a very basic &lt;code&gt;div&lt;/code&gt; which contains 9 more boxes each with different color and also has a number on it.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Static Position (default value)
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;position: static&lt;/code&gt; property allows elements to be positioned in the normal flow of the document.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
Note: This is the default value.

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

&lt;/div&gt;



&lt;p&gt;The below boxes has &lt;code&gt;position: static;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3z23ba2m6hc5lgs70jam.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3z23ba2m6hc5lgs70jam.png" alt="Position static" width="800" height="416"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://codesandbox.io/p/sandbox/learn-css-positioning-k859pg?file=%2Fstyles.css&amp;amp;layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clxsp6vm200062869nysqztgl%2522%252C%2522sizes%2522%253A%255B100%252C0%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clxsp6vm2000228696ojapkvm%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clxsp6vm200032869mc9tkczd%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clxsp6vm200052869tkmmlrj0%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B40%252C60%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clxsp6vm2000228696ojapkvm%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clxsp6vm1000128696ofucqww%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Findex.html%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522id%2522%253A%2522clxt1tqmm000228693683crp6%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522initialSelections%2522%253A%255B%257B%2522startLineNumber%2522%253A37%252C%2522startColumn%2522%253A23%252C%2522endLineNumber%2522%253A37%252C%2522endColumn%2522%253A23%257D%255D%252C%2522filepath%2522%253A%2522%252Fstyles.css%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%255D%252C%2522id%2522%253A%2522clxsp6vm2000228696ojapkvm%2522%252C%2522activeTabId%2522%253A%2522clxt1tqmm000228693683crp6%2522%257D%252C%2522clxsp6vm200052869tkmmlrj0%2522%253A%257B%2522id%2522%253A%2522clxsp6vm200052869tkmmlrj0%2522%252C%2522activeTabId%2522%253A%2522clxsp8zvm004a2869147v1jcv%2522%252C%2522tabs%2522%253A%255B%257B%2522type%2522%253A%2522UNASSIGNED_PORT%2522%252C%2522port%2522%253A0%252C%2522id%2522%253A%2522clxsp8zvm004a2869147v1jcv%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522path%2522%253A%2522%252F%2522%257D%255D%257D%252C%2522clxsp6vm200032869mc9tkczd%2522%253A%257B%2522tabs%2522%253A%255B%255D%252C%2522id%2522%253A%2522clxsp6vm200032869mc9tkczd%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Afalse%252C%2522showSidebar%2522%253Afalse%252C%2522sidebarPanelSize%2522%253A0%257D" rel="noopener noreferrer"&gt;Eg codesandbox link&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  CSS Relative Position
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;position: relative;&lt;/code&gt; property positions the element relative to its original position. The &lt;code&gt;top, right, bottom, left&lt;/code&gt; properties is used to move the element accordingly.&lt;/p&gt;

&lt;p&gt;Here, we give &lt;code&gt;position: relative;&lt;/code&gt; to box one and make it &lt;code&gt;top: 35px&lt;/code&gt; and &lt;code&gt;right: 5px;&lt;/code&gt;. So, the box one moves to the top and right to its original position.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
Note: The space is still preserved in the original position of the element.

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

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz1f7awzqpp76y3g3ndhn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz1f7awzqpp76y3g3ndhn.png" alt="Position relative" width="800" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Absolute Position
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;position: absolute;&lt;/code&gt; property removes the element completely from the normal flow of the document.&lt;/p&gt;

&lt;p&gt;It is positioned &lt;em&gt;relative&lt;/em&gt; to the nearest parent element having a position other than &lt;code&gt;static&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If there is no parent with position other than &lt;code&gt;static&lt;/code&gt;, then it is positioned relative to the document itself.&lt;/p&gt;

&lt;p&gt;Below both the boxes has &lt;code&gt;top: 50px; and right: 50px;&lt;/code&gt; only the difference is first eg is relative to the document(webpage) and second eg is relative to the border container.&lt;/p&gt;

&lt;p&gt;Here, the box one is no longer the part of border container.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffr2b81eqyx09kopagliu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffr2b81eqyx09kopagliu.png" alt="Position absolute" width="800" height="362"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
Note: An absolutely positioned element loses original space in the document flow.

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  CSS Fixed Position
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;position: fixed;&lt;/code&gt; property positions an element to remain fixed in the same position, even when the page is scrolled. It is similar to the absolute value, but it remains relative to the viewport at all times.&lt;/p&gt;

&lt;p&gt;Here, the box one is positioned &lt;code&gt;50px from top and right&lt;/code&gt; it will remain at the same position even when the page is scrolled.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm4ceb7utqwjywvo2zjar.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm4ceb7utqwjywvo2zjar.gif" alt="Position fixed" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Sticky Position
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;position: fixed;&lt;/code&gt; positions the element in the combination of &lt;code&gt;fixed&lt;/code&gt; and &lt;code&gt;relative&lt;/code&gt; values.&lt;/p&gt;

&lt;p&gt;This property allows the element to stick to specific position in the viewport as you scroll, but only within its containing element.&lt;/p&gt;

&lt;p&gt;When you first scroll, the element behaves like it has relative positioning. It moves with the flow of the document.&lt;/p&gt;

&lt;p&gt;Once the element reaches the specified position (defined by top, right, bottom, or left), it "sticks" to that position. It will stay in that position as you continue to scroll.&lt;/p&gt;

&lt;p&gt;The element will stop sticking and resume normal document flow once the containing element (the nearest scrollable ancestor) is out of view.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7qkkocv3x81tnyx7n76e.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7qkkocv3x81tnyx7n76e.gif" alt="Position sticky" width="800" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Thank you for reading!! If you find this helpful; drop your reactions and share this piece with others. Let me know into the comments, "Why you suck at CSS?"&lt;/p&gt;

&lt;p&gt;You can also stay connected with me by following me here and on &lt;a href="https://twitter.com/JiitendraC" rel="noopener noreferrer"&gt;X&lt;/a&gt;, &lt;a href="https://github.com/J11tendra/" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;, and &lt;a href="https://www.linkedin.com/in/jiitendrachoudhary/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Everything You Need to Know About CSS Backgrounds</title>
      <dc:creator>Jitendra Choudhary</dc:creator>
      <pubDate>Tue, 11 Jun 2024 17:15:22 +0000</pubDate>
      <link>https://dev.to/jitendrachoudhary/everything-you-need-to-know-about-css-backgrounds-3dle</link>
      <guid>https://dev.to/jitendrachoudhary/everything-you-need-to-know-about-css-backgrounds-3dle</guid>
      <description>&lt;p&gt;We can do some cool things with CSS background property such as creating a hero image or using it to do some cool parallax effects. In this article, we'll pretty much everything you need to know about CSS background property.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Background-color Property
&lt;/h2&gt;

&lt;p&gt;Below you have a simple box with the class "container"; you can directly set the background color of the container by applying &lt;code&gt;background-color: &amp;lt;any color you want, let's say violet&amp;gt;&lt;/code&gt; to the container itself. That's it it's that simple to change the background color, however, you can use many different colors like rgb, rgba, hex, and hsl.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/kd88nl"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Background-image Property
&lt;/h2&gt;

&lt;p&gt;Now you have to change the background image so you will set the background image of the container. You use &lt;code&gt;background-image: url(&amp;lt;paste the url of the image; assets/lion.png&amp;gt;)&lt;/code&gt;. You can see the box has a background image but it is not what we expected. this is because the size of the image is much smaller than the size of the box or you can say the width and height of the box. So by default, it tends to fill up the space by repeating the same image vertically (on the y-axis) and horizontally (on the x-axis) until it covers the whole space.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/8kjpzw"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Background-repeat Property
&lt;/h2&gt;

&lt;p&gt;Like you expected to have a single image in the box and not allow the image to repeat; this can be achieved by using &lt;code&gt;background-repeat: no-repeat&lt;/code&gt; here you have a bunch of options such as &lt;code&gt;background-repeat: repeat-x&lt;/code&gt; and &lt;code&gt;background-repeat: repeat-y&lt;/code&gt; which is pretty much self-explanatory.&lt;/p&gt;

&lt;h3&gt;
  
  
  background-repeat: no-repeat
&lt;/h3&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/yd4rhv"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  background-repeat: repeat-x
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ia3yiso0se3zjyp44g8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ia3yiso0se3zjyp44g8.png" alt="css-background-repeat-x" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  background-repeat: repeat-y
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa8klxw1rpwl2rf600jxr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa8klxw1rpwl2rf600jxr.png" alt="css-background-repeat-y" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Background-size Property
&lt;/h2&gt;

&lt;p&gt;Now you see you have a image taking a small portion of the box but you want to make this image take up the space. CSS has a solution for this as well. You can use &lt;code&gt;background-size: &amp;lt;any pixel values, cover, contain&amp;gt;;&lt;/code&gt; often &lt;code&gt;background-size: 150px;&lt;/code&gt; is not preferred because you need to adjust the image size of every viewport.&lt;/p&gt;

&lt;h3&gt;
  
  
  background-size: auto;
&lt;/h3&gt;

&lt;p&gt;Scales the background image in the corresponding direction such that its intrinsic proportions are maintained.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/dkwzf6"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;background-size auto with repeat&lt;/strong&gt;
&amp;lt;!-- background-size auto img --&amp;gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuoj04b53lfldh67moa4u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuoj04b53lfldh67moa4u.png" alt="css-background-size-auto-repeat" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;background-size auto with no-repeat&lt;/strong&gt;
&amp;lt;!-- background-size auto img no repeat --&amp;gt;
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fglup14ft863sbmd7cw05.png" alt="css-background-size-auto-no-repeat" width="800" height="403"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  background-size: cover;
&lt;/h3&gt;

&lt;p&gt;Scales the image (while preserving its ratio) to the smallest possible size to fill the container (that is: both its height and width completely cover the container), leaving no space. If the proportions of the background differ from the element, the image is cropped vertically or horizontally.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7wctin2tjb2klc49rxxm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7wctin2tjb2klc49rxxm.png" alt="css-background-size-cover" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  background-size: contain;
&lt;/h3&gt;

&lt;p&gt;Scales the image as large as possible within its container without cropping or stretching it. If the container is larger than the image, this will result in image tiling, unless the background-repeat property is set to no-repeat.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fti92mhxlr9mloqo13i4q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fti92mhxlr9mloqo13i4q.png" alt="css-background-size-contain" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Background-position Property
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;background-position&lt;/code&gt; property sets the initial position of the background image. The position is relative to the positioning layer set by &lt;code&gt;background-origin&lt;/code&gt;. It is a shorthand property for &lt;code&gt;background-position-x&lt;/code&gt; and &lt;code&gt;background-position-y&lt;/code&gt;; the first value is positioning on the x-axis and the second on the y-axis.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Keyword values */&lt;/span&gt;
&lt;span class="nt"&gt;background-position&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;top&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;background-position&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;bottom&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;background-position&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;left&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;background-position&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;right&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;background-position&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;center&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="c"&gt;/* on the x-axis and y-axis */&lt;/span&gt;
&lt;span class="nt"&gt;background-position&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;center&lt;/span&gt; &lt;span class="nt"&gt;top&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;background-position&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;left&lt;/span&gt; &lt;span class="nt"&gt;center&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/lxkcp7"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  background-position-x;
&lt;/h3&gt;

&lt;p&gt;It sets the initial horizontal position (on the x-axis) of the background image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Keyword values */&lt;/span&gt;
&lt;span class="nt"&gt;background-position-x&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;left&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;background-position-x&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;center&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;background-position-x&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;right&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F36spdrf5odbzij49xi4g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F36spdrf5odbzij49xi4g.png" alt="css-background-position-x" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  background-position-y;
&lt;/h3&gt;

&lt;p&gt;It sets the initial vertical position (on the y-axis) of the background image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Keyword values */&lt;/span&gt;
&lt;span class="nt"&gt;background-position-y&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;top&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;background-position-y&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;center&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;background-position-y&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;bottom&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa8klxw1rpwl2rf600jxr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa8klxw1rpwl2rf600jxr.png" alt="css-background-position-y" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Background-attachment Property
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;background-attachment&lt;/code&gt; property sets whether a background image's position is fixed within the viewport, or scrolls with its containing block. For this, you need to add text to the box to see the effect.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Keyword values */&lt;/span&gt;
&lt;span class="nt"&gt;background-attachment&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;fixed&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;background-attachment&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;local&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;background-attachment&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;scroll&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  background-attachment: fixed;
&lt;/h3&gt;

&lt;p&gt;The background is fixed relative to the viewport. Even if an element has a scrolling mechanism, the background doesn't move with the element. (This is not compatible with background-clip: text.)&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/spjcpn"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  background-attachment: scroll;
&lt;/h3&gt;

&lt;p&gt;The background is fixed relative to the element itself and does not scroll with its contents. (It is effectively attached to the element's border.)&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/zjz5kh"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  background-attachment: local;
&lt;/h3&gt;

&lt;p&gt;The background is fixed relative to the element's contents. If the element has a scrolling mechanism, the background scrolls with the element's contents and the background painting area and background positioning area are relative to the scrollable area of the element rather than to the border framing them.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Background-clip Property
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;background-clip&lt;/code&gt; property is used to define how far the background image or color of an element should extend within the element. It determines whether the background should be drawn within the &lt;code&gt;border-box&lt;/code&gt;, &lt;code&gt;padding-box&lt;/code&gt;, or &lt;code&gt;content-box&lt;/code&gt; of an element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* keyword values */&lt;/span&gt;
&lt;span class="nt"&gt;background-clip&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;border-box&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;background-clip&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;padding-box&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;background-clip&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;content-box&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  background-clip: border-box;
&lt;/h3&gt;

&lt;p&gt;The background extends to the outer edge of the border. This is the default value.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/zh22yl"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  background-clip: padding-box;
&lt;/h3&gt;

&lt;p&gt;The background extends to the outer edge of the padding. The border area is not covered.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/5wddzl"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  background-clip: content-box;
&lt;/h3&gt;

&lt;p&gt;The background is clipped to the edge of the content box. The padding and border areas are not covered.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/lhf9kc"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Background shorthand Property
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;background&lt;/code&gt; shorthand property is a convenient way to set multiple background-related properties at once. This can include background color, image, position, size, repeat, origin, clip, and attachment. Using the shorthand property can help to make it more readable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;background&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;background-color&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
 &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;background-image&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
 &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;background-position&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;background-size&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
 &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;background-repeat&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
 &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;background-origin&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
 &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;background-clip&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
 &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;background-attachment&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
 &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;initial&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nt"&gt;inherit&lt;/span&gt;&lt;span class="o"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;When using the background shorthand, the values should be specified in the order outlined above. However, not all values need to be included. If a value is omitted, the default for that property will be applied.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Whether you're setting a simple background color or creating complex layered backgrounds with images, CSS provides the flexibility to achieve your desired design.&lt;/p&gt;

&lt;p&gt;Mastering CSS &lt;code&gt;background&lt;/code&gt; properties is essential for any web developer aiming to create engaging and visually captivating websites.&lt;/p&gt;

&lt;p&gt;Thanks for reading this!! If you find this helpful; drop your reactions and share this piece with others.&lt;/p&gt;

&lt;p&gt;You can also stay connected with me by following me here and on &lt;a href="https://x.com/jiitendraC" rel="noopener noreferrer"&gt;X&lt;/a&gt;, and &lt;a href="https://www.linkedin.com/in/jiitendrachoudhary/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>css</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Learn CSS BOX MODEL</title>
      <dc:creator>Jitendra Choudhary</dc:creator>
      <pubDate>Fri, 31 May 2024 18:14:14 +0000</pubDate>
      <link>https://dev.to/jitendrachoudhary/learn-css-box-model-mgh</link>
      <guid>https://dev.to/jitendrachoudhary/learn-css-box-model-mgh</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;On the web everything is a box literally everything all the elements, images, buttons, paragraphs, videos, and everything. With everything being a box it has a BOX MODEL applied. So what is a CSS BOX MODEL? In this article, we will learn CSS BOX MODEL. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F23v05gosqlzaecjh8zai.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F23v05gosqlzaecjh8zai.png" alt="GSAP-everything-is-box-on-web" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a BOX MODEL?
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;The CSS box model as a whole applies to block boxes and defines how the different parts of a box — margin, border, padding, and content — work together to create a box that you can see on a page. Inline boxes use just some of the behavior defined in the box model.&lt;/em&gt; - mdn web docs&lt;/p&gt;

&lt;p&gt;The BOX MODEL consists of the content, padding, border and margin.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuskxiy5vzm2cpw53mlkq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuskxiy5vzm2cpw53mlkq.png" alt="Box-Model-CSS" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Parts of a box
&lt;/h2&gt;

&lt;p&gt;Making up a block box in CSS we have this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Content box: In this box your actual content is displayed; you can alter this using properties like &lt;u&gt;height&lt;/u&gt; and &lt;u&gt;width&lt;/u&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/trglgq?module=%2Fstyles.css"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Padding box: The padding is the area around the content as white space; you can alter it using &lt;u&gt;padding&lt;/u&gt; and related properties. Basically padding is creates a space inside an element.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/xcj98z?module=%2Fstyles.css"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Border box: The border box wraps around padding box if any otherwise on the content box; size it using &lt;u&gt;border&lt;/u&gt; and related properties.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/tqw8wk?module=%2Fstyles.css"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Margin box: The margin is the outermost layer around the content, padding, and border as white space between this box and other elements; you can size it using &lt;u&gt;margin&lt;/u&gt; and related properties.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/fnlqch?module=%2Fstyles.css"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  The standard CSS BOX MODEL
&lt;/h2&gt;

&lt;p&gt;In the standard box model, if you set height and width property value on a box, these values defines the height and width of the &lt;em&gt;content box&lt;/em&gt;. Any padding and borders are then added to get the actual size of the box.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note: However, the margin takes space on the page it is not counted towards the size of the box.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If we assume that we have the following box with some CSS properties:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.box&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;300px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;200px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;25px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;magenta&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The actual size of the box will be width (horizontal)(300 + 10 + 10 + 5 + 5) and height (vertical)(200 + 10 + 10 + 5 + 5).&lt;/p&gt;

&lt;h2&gt;
  
  
  The alternate CSS BOX MODEL
&lt;/h2&gt;

&lt;p&gt;In the alternate box model, the size is of the box is just the simple width and height of the box.&lt;/p&gt;

&lt;p&gt;To apply the alternate box model, we use &lt;code&gt;box-sizing&lt;/code&gt; property on it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.alternate&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;box-sizing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;border-box&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we assume that we have the following box with some CSS properties:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.box&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;300px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;200px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;25px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;magenta&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The actual size of the box will be width (horizontal)(300) and height (vertical)(200).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The alternate box model is popular among developers and here is how you can apply to the elements:&lt;/strong&gt;&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;html&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;box-sizing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;border-box&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="o"&gt;*,&lt;/span&gt;
&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nd"&gt;::after&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nd"&gt;::before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;box-sizing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inherit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Play with CSS BOX MODEL
&lt;/h2&gt;

&lt;p&gt;Ignore the boilerplate, I create two divs with class name &lt;u&gt;box&lt;/u&gt;. I also add one more class &lt;u&gt;alternate&lt;/u&gt; to the second div. Now both the divs will have same properties except the alternate class.&lt;/p&gt;

&lt;p&gt;The class &lt;strong&gt;box&lt;/strong&gt; has following CSS properties:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.box&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;200px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;150px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;25px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;magenta&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The class &lt;strong&gt;alternate&lt;/strong&gt; has following CSS properties:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.alternate&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;box-sizing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;border-box&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/kx38jx?module=%2Fstyles.css"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;That's it for BOX MODEL; As everything on web is a box it is very important to learn the fundamentals of CSS. Learning box modeling enables you to manipulate and structure elements on the page.&lt;/p&gt;

&lt;p&gt;Thanks for this reading!! If you find this helpful; drop your reactions and share this piece with others.&lt;/p&gt;

&lt;p&gt;You can also stay connected with me by following me here and on &lt;a href="https://twitter.com/JiitendraC" rel="noopener noreferrer"&gt;X&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/jiitendrachoudhary/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>What is React Hydration?</title>
      <dc:creator>Jitendra Choudhary</dc:creator>
      <pubDate>Sun, 21 Apr 2024 17:35:07 +0000</pubDate>
      <link>https://dev.to/jitendrachoudhary/what-is-react-hydration-2bc3</link>
      <guid>https://dev.to/jitendrachoudhary/what-is-react-hydration-2bc3</guid>
      <description>&lt;p&gt;Before surfing into the concept of hydration in React, it's essential to grasp some fundamental concepts: client-side rendering (CSR) and server-side rendering (SSR).&lt;/p&gt;

&lt;h2&gt;
  
  
  Client-side rendering (CSR)
&lt;/h2&gt;

&lt;p&gt;Client-side rendering involves rendering all pages directly in the browser using JavaScript. In this approach, the browser handles all data-fetching tasks, leading to slower page loading times and potentially a subpar user experience. ReactJS serves as a prime example of a client-side rendering library.&lt;/p&gt;

&lt;h2&gt;
  
  
  Server-side rendering (SSR)
&lt;/h2&gt;

&lt;p&gt;Server-side rendering, on the other hand, utilizes servers' request-response processes to render pages using JavaScript. Data fetching is performed by the servers, resulting in a better user experience. SSR loads HTML content initially, providing users with some content, while JavaScript loads in the background. Unlike CSR, SSR doesn't present a blank page during the initial render. This initial rendering disparity becomes apparent when dealing with larger applications with frequent state changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Hydration in React
&lt;/h2&gt;

&lt;p&gt;Many developers encounter confusion surrounding the term "hydration" in React. But what exactly is hydration? When a server sends HTML to the browser, it's rendered on the client side. However, this HTML lacks React components. Hydration is the process by which React attaches itself to this existing HTML. It attempts to attach event listeners to the HTML, enabling control over all DOM nodes within it. Essentially, hydration allows React to integrate seamlessly with pre-rendered HTML, enhancing interactivity and functionality.&lt;/p&gt;

&lt;p&gt;With the latest version of React (v18), developers can now render components on the server side. This means that the HTML generated by the server and sent to the client also originates from React. The &lt;code&gt;HydrateRoot&lt;/code&gt; function facilitates the display of React components within a DOM node whose HTML content was previously generated by react-dom/server`.&lt;/p&gt;

&lt;p&gt;Understanding React hydration is crucial for optimizing client-side rendering and improving user experiences. By seamlessly integrating React with server-rendered HTML, developers can achieve faster initial renders and better overall performance in their web applications.&lt;/p&gt;

&lt;p&gt;Rendering and hydration are both crucial processes in React, but they serve different purposes and are used in different contexts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rendering
&lt;/h3&gt;

&lt;p&gt;Rendering in React refers to the process of converting React components into DOM elements and displaying them on the screen. When you use &lt;code&gt;ReactDOM.render()&lt;/code&gt; in your code, you're instructing React to render your component hierarchy into a specified DOM node.&lt;/p&gt;

&lt;p&gt;For example,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwx483352107vk6jjthtv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwx483352107vk6jjthtv.png" alt="render-code-sample" width="800" height="248"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;React renders the &lt;code&gt;&amp;lt;App /&amp;gt;&lt;/code&gt; component with the specified props (&lt;code&gt;name="Jitendra"&lt;/code&gt;) into the DOM node with the id &lt;code&gt;root&lt;/code&gt;. This results in the component being displayed on the webpage as &lt;em&gt;"If you find my blog helpful consider dropping an emoji"&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hydration
&lt;/h3&gt;

&lt;p&gt;Hydration, on the other hand, is the process of attaching event listeners and reattaching event handlers to the server-rendered HTML. It's a crucial step when React is used for server-side rendering (SSR), as it allows React to take over the client-side interactivity of a page that was initially rendered on the server.&lt;/p&gt;

&lt;p&gt;For example,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw6l5eid3gai1wj8g82wj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw6l5eid3gai1wj8g82wj.png" alt="hydrate-code-sample" width="800" height="301"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You're attempting to hydrate the server-rendered HTML with React. However, since the server-rendered HTML doesn't contain the expected &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; element, React throws a warning because it expects the server HTML to match the client HTML.&lt;/p&gt;

&lt;h3&gt;
  
  
  hydrateRoot() API
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;hydrateRoot()&lt;/code&gt; API is a more recent addition to React, introduced in React 18. It replaces the deprecated &lt;code&gt;hydrate()&lt;/code&gt; method. This API allows you to hydrate a root React node with server-rendered HTML content.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffg94ubc3rygooygq0ay7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffg94ubc3rygooygq0ay7.png" alt="hydrateRoot-API" width="800" height="306"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;domNode&lt;/code&gt;: The DOM element that was rendered as the root element in the tree.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;reactNode&lt;/code&gt;: The React node used to render the existing HTML, typically a JSX file like &lt;code&gt;App.js&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Options&lt;/code&gt;: An optional object with options for the React root.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Some key points to remember:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;hydrateRoot()&lt;/code&gt; compares the rendered content and the server-rendered content and warns you of any mismatches during hydration.&lt;br&gt;
If the HTML content is not rendered beforehand, you can't use &lt;code&gt;hydrateRoot()&lt;/code&gt;. In this case, &lt;code&gt;createRoot()&lt;/code&gt; has to be used.&lt;br&gt;
It's typically best to have only one &lt;code&gt;hydrateRoot()&lt;/code&gt; call in your entire React app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Looking forward to React 19, there's a sense of anticipation for what's next.&lt;/p&gt;

&lt;p&gt;If you have read this far and find my blogs worth reading feel free to follow me here so you can get my next blog update straight in your feed.&lt;br&gt;
Interested in connecting on &lt;strong&gt;&lt;a href="https://twitter.com/jiitendraC" rel="noopener noreferrer"&gt;X&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/jiitendrachoudhary/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;, &lt;a href="https://github.com/J11tendra/" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/strong&gt;?&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>Lessons I learned as a Self Taught Developer</title>
      <dc:creator>Jitendra Choudhary</dc:creator>
      <pubDate>Sun, 14 Apr 2024 16:03:30 +0000</pubDate>
      <link>https://dev.to/jitendrachoudhary/lessons-i-learned-as-a-self-taught-developer-49b5</link>
      <guid>https://dev.to/jitendrachoudhary/lessons-i-learned-as-a-self-taught-developer-49b5</guid>
      <description>&lt;h2&gt;
  
  
  Table of Content
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;Fundamentals is the King&lt;/li&gt;
&lt;li&gt;Big Tech is not the end of the World&lt;/li&gt;
&lt;li&gt;Networking is the Key&lt;/li&gt;
&lt;li&gt;The stack is irrelevant&lt;/li&gt;
&lt;li&gt;Learning is Real&lt;/li&gt;
&lt;li&gt;Programming-is-Hard&lt;/li&gt;
&lt;li&gt;Importance of Real World Experience&lt;/li&gt;
&lt;li&gt;Become a Master of One Trade&lt;/li&gt;
&lt;li&gt;Learn How to Collaborate&lt;/li&gt;
&lt;li&gt;Project based Learning&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0wabybbog6t2xb7qo3mz.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0wabybbog6t2xb7qo3mz.jpg" alt="Self Taught Coder Owl" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;“The most disastrous thing that you can ever learn is your first programming language.” ― Alan Kay&lt;/p&gt;


&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In this blog Jitendra shares his 10 most important lessons he learned as a self taught developer. So if you in the same boat and your time is worth trying to implement these lessons in your programming life. Through my experience, I've come to learn several crucial lessons that have shaped my approach to coding and career development. In this article, I'll share some insights from my journey as a self-taught developer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fundamentals is the King
&lt;/h2&gt;

&lt;p&gt;Many times you will hear the buzz “know the fundamentals”!! But I used to wonder why. Fundamentals are the building blocks of everything that exists out there. Knowing the fundamentals will help you understand the logic, the principles, and the purpose of what you are learning. Let's understand this with an example: learning the basics of programming is like knowing the alphabet, letters, words, etc., and then choosing which story to write about. The story is like a framework that will trend and flop, but the fundamentals of the language will remain. So, don’t be a React king first; be a JavaScript king.&lt;/p&gt;

&lt;h2&gt;
  
  
  Big Tech is not the end of the world
&lt;/h2&gt;

&lt;p&gt;Working at Big Tech may not be the best experience for programmers who are looking for flexibility. Often, in big tech, you will end up working on a specific part of the company’s codebase. Whereas, working at a startup, you can have major control over things and, hence, a greater impact on the company. If you are looking for greater impact and learning and more control over things, big tech might not be the thing for you. Often, working in a startup means you can work on cool, creative projects, and innovation is your thing. Working at Big Tech gets you respect in the tech community and watches your bank account max out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Networking is the key
&lt;/h2&gt;

&lt;p&gt;Building a strong network within the tech community is invaluable. Networking opens doors to opportunities, mentorship, and collaboration. Attend meetups, conferences, and online forums to connect with like-minded individuals. Share your knowledge, seek advice, and be open to learning from others. Your network can play a significant role in your career growth and development as a self-taught developer.&lt;/p&gt;

&lt;h2&gt;
  
  
  The stack is irrelevant
&lt;/h2&gt;

&lt;p&gt;It's natural to love the tools you use every day, but they're not as important as you might think. New tools are built to solve problems that their predecessors failed to solve. New technology can be a lot of fun, but becoming too attached to it can be harmful. So, be sure to learn about the latest technology, but also remember to use it as a tool, not a crutch. It's foolish to ignore new technology and stick with what you know. Instead, challenge yourself to explore new languages, frameworks, and patterns, because that's how you'll grow and expand your knowledge. Focus on learning because that's what makes work enjoyable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Learning is Real
&lt;/h2&gt;

&lt;p&gt;As a self-taught developer, the learning never stops. Embrace a growth mindset and be prepared to continuously update your skills and knowledge. Explore new technologies, languages, and frameworks to stay relevant in the ever-evolving tech industry. Take online courses, read books, and engage in hands-on projects to deepen your understanding. Remember, learning is a lifelong journey, and staying curious is the key to success.&lt;/p&gt;

&lt;h2&gt;
  
  
  Programming-is-Hard
&lt;/h2&gt;

&lt;p&gt;Undoubtedly, programming can be challenging. It requires patience, problem-solving skills, and perseverance. Don't be discouraged by setbacks or failures; instead, view them as opportunities for growth. Break down complex problems into smaller, manageable tasks and tackle them one step at a time. Practice regularly, and seek help when needed. With determination and practice, you can overcome any programming challenge.&lt;/p&gt;

&lt;h2&gt;
  
  
  Importance of Real-World Experience
&lt;/h2&gt;

&lt;p&gt;While theoretical knowledge is essential, nothing beats real-world experience. Internships, freelance projects, or contributing to open-source initiatives can provide valuable hands-on experience. These opportunities allow you to apply your skills in a practical setting, learn from experienced professionals, and build a portfolio of work. Employers value candidates with both theoretical knowledge and practical experience, so don't underestimate the importance of gaining real-world exposure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Become a Master of One Trade
&lt;/h2&gt;

&lt;p&gt;Rather than spreading yourself too thin, focus on mastering one programming language or technology stack. Specializing in a specific area allows you to develop deep expertise and differentiate yourself in the job market. Identify your interests and strengths, and invest time and effort into honing your skills in that particular domain. While it's essential to have a broad understanding of various technologies, becoming a master of one trade can open doors to exciting career opportunities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Learn How to Collaborate
&lt;/h2&gt;

&lt;p&gt;Collaboration is essential in the world of software development. Learn how to effectively communicate and collaborate with team members, whether they're developers, designers, or stakeholders. Practice agile methodologies, participate in code reviews, and contribute to group projects to enhance your collaborative skills. Being able to work effectively in a team not only improves the quality of your work but also fosters a positive and productive work environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project-based Learning
&lt;/h2&gt;

&lt;p&gt;Hands-on projects are an excellent way to reinforce your learning and showcase your skills to potential employers. Work on personal projects or contribute to open-source initiatives to apply what you've learned in a real-world context. Projects allow you to experiment with different technologies, solve practical problems, and build a portfolio of work that demonstrates your abilities. Focus on creating projects that align with your interests and career goals, and don't be afraid to step out of your comfort zone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Teaching yourself programming is a journey filled with challenges and opportunities for growth. By implementing this points into your programming journey you can succeed as self taught developer.&lt;/p&gt;

&lt;p&gt;If you have read this far and find my blogs worth reading feel free to follow me here so you can get my next blog update straight in your feed.&lt;/p&gt;

&lt;p&gt;Interested in connecting on X? Say me Hi at &lt;a href="https://twitter.com/JiitendraC" rel="noopener noreferrer"&gt;@JitendraC&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>What is MQTT Protocol?</title>
      <dc:creator>Jitendra Choudhary</dc:creator>
      <pubDate>Mon, 01 Apr 2024 07:32:07 +0000</pubDate>
      <link>https://dev.to/jitendrachoudhary/what-is-mqtt-protocol-2l7a</link>
      <guid>https://dev.to/jitendrachoudhary/what-is-mqtt-protocol-2l7a</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;What is MQTT?&lt;/li&gt;
&lt;li&gt;Importance of MQTT in IoT&lt;/li&gt;
&lt;li&gt;Understanding MQTT&lt;/li&gt;
&lt;li&gt;What are MQTT Components?&lt;/li&gt;
&lt;li&gt;Understanding MQTT With An Example&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Welcome to the second article of our API series! In this article, we will learn about the MQTT protocol and its architecture, components, and real-world applications. If you are new to the series, we recommend starting with our first article where we discussed the basics of APIs and how they function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you haven't read the first article yet, be sure to check it out:&lt;/strong&gt; &lt;a href="https://dev.to/jitendrachoudhary/what-is-an-api-5225"&gt;What is an API and How Does it Work?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let's continue with the MQTT protocol.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm3ktjpdapni7r9pmzue1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm3ktjpdapni7r9pmzue1.png" alt="IoT?" width="800" height="568"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is MQTT?
&lt;/h2&gt;

&lt;p&gt;MQTT stands for Messaging Queuing Telemetry Transport. MQTT is a standard messaging protocol for machine-to-machine communication. Smart home systems, scanners, sensors, and other IoT (Internet of Things) send and retrieve data over a network having a limited bandwidth. For devices having limited hardware capabilities, MQTT proves to be an efficient architecture for communication.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flw6byxctr8f94dh7zoli.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flw6byxctr8f94dh7zoli.png" alt="Computer Hardware?" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Importance of MQTT in IoT
&lt;/h2&gt;

&lt;p&gt;MQTT is the standard protocol for IoT devices to communicate with other machines. here are some main reasons:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lightweight And Scalable&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;MQTT can be implemented on IoT devices with minimal usage of resources. It can even be used on microcontrollers. MQTT headers are small so that you can optimize the network bandwidth. As implementation of MQTT requires fewer resources it also requires less code that consumes very little power. MQTT also has built-in features so you get support for large IoT devices for communication.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reliable And Secure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;IoT devices connect via unreliable networks. MQTT re-connects quickly with built-in features. It offers three levels of quality-of-service for IoT use cases. MQTT also makes it easy to encrypt messages and authenticate devices and users using modern protocols such as OAuth and TLS1.3.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding MQTT
&lt;/h2&gt;

&lt;p&gt;MQTT protocol uses a publish/service model for communication. Whereas, in HTTP a client sends a request for data or resources and the server responds with data after authentication. This is a very straightforward approach. However, In MQTT protocol works on the principles of the publish/subscribe model where it decouples the publisher (message provider) from the subscriber (message receiver). There is a message broker which handles all the communication between the publisher and the subscriber. The message broker filters the messages received from the publisher and correctly sends them to its subscriber; not exposing the two parties to each other. The broker does the decoupling as below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Space decoupling&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The two parties (publisher and subscriber) are not aware of each other's network information like IP addresses, port numbers, or even location.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Time decoupling&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The publisher and subscriber don’t run or have network connectivity at the same time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Synchronization decoupling&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Both publishers and subscribers can send or receive messages independently without interrupting each other. For example, the subscriber does not have to wait for the publisher to send a message.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are MQTT components?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhmv1pepx9ekmfa7n2yfo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhmv1pepx9ekmfa7n2yfo.png" alt="How MQTT Works(diagram)?" width="800" height="568"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MQTT Client&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A MQTT client is anything as big as a server or as small as a microcontroller that runs a MQTT library. If the client is sending messages, it acts as a publisher, and if it is receiving messages, it acts as a subscriber. Any device that communicates using MQTT over a network can be called an MQTT client device.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MQTT broker&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The MQTT broker is a vital component that acts as a mediator between different clients. Its primary functions include receiving and filtering messages, identifying subscribed clients, and delivering the messages to them. In addition, the MQTT broker is responsible for other critical tasks such as authenticating and authorizing MQTT clients, forwarding messages to other systems for analysis, and managing missed messages and client sessions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MQTT connection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To establish communication, clients and brokers use an MQTT connection. The MQTT client initiates the connection by sending a CONNECT message to the broker. The broker acknowledges the connection by responding with a CONNACK message. Communication between clients and the broker requires a TCP/IP stack. It's important to note that clients can only connect with the broker and not with each other.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding MQTT With An Example
&lt;/h2&gt;

&lt;p&gt;Imagine you have a smart home setup with various IoT devices like sensors, switches, and lights. You want to control and monitor these devices remotely using your smartphone or computer. MQTT can facilitate communication between your devices and your control interface (smartphone or computer) efficiently and reliably.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjqgz49osdhdlg02wo0gi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjqgz49osdhdlg02wo0gi.png" alt="Smart Home System?" width="800" height="568"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Setup&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You have an MQTT broker installed on a server (which could be a cloud-based service or a local server).&lt;/li&gt;
&lt;li&gt;Each IoT device in your home (e.g., temperature sensors, motion sensors, smart lights) is equipped with an MQTT client.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Publishing Data&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your temperature sensor periodically measures the temperature in a room.&lt;/li&gt;
&lt;li&gt;When the temperature reading is taken, the sensor publishes this data to a specific MQTT topic, such as "home/living_room/temperature."&lt;/li&gt;
&lt;li&gt;Similarly, your motion sensor detects movement and publishes an event to the topic "home/kitchen/motion."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Subscribing to Topics&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Meanwhile, your smartphone or computer is running an MQTT client application.&lt;/li&gt;
&lt;li&gt;You subscribe to the topics you're interested in, such as "home/+/temperature" to receive temperature data from all rooms, or "home/+/motion" to monitor motion events in different areas.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Receiving and Acting on Data&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When a temperature reading is published to the "home/living_room/temperature" topic, your MQTT client on the smartphone receives this data.&lt;/li&gt;
&lt;li&gt;The client application can then display the temperature on your smartphone's interface in real-time.&lt;/li&gt;
&lt;li&gt;If the motion sensor in the kitchen publishes a "motion detected" event to the "home/kitchen/motion" topic, your smartphone receives this notification.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;5. Controlling Devices&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Let's say you want to turn on the lights in your living room remotely.&lt;/li&gt;
&lt;li&gt;You send a command to the MQTT broker, publishing a message to the topic "home/living_room/lights/set" with the desired action (e.g., "turn on").&lt;/li&gt;
&lt;li&gt;The MQTT broker forwards this command to the MQTT client running on the smart light switch in your living room.&lt;/li&gt;
&lt;li&gt;The smart light switch receives the command and turns on the lights accordingly.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;MQTT is a reliable and lightweight protocol that connects and controls IoT devices over constrained networks. It uses a publish/subscribe model that ensures efficient communication and enables remote monitoring and control. Its security features and support for various quality-of-service levels make it indispensable for a wide range of applications.&lt;/p&gt;

&lt;p&gt;If you have read this far and find my blogs worth reading feel free to follow me here so you can get my next blog update straight in your feed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interested in connecting on X? Say me Hi at &lt;a href="https://twitter.com/jiitendraC" rel="noopener noreferrer"&gt;@JitendraC&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Related Article: A Comprehensive Guide to MQTT Protocol
&lt;/h2&gt;

&lt;p&gt;If you found this article informative and want to learn more about the MQTT protocol, be sure to check out &lt;a href="https://mobidev.biz/blog/mqtt-5-protocol-features-iot-development" rel="noopener noreferrer"&gt;MQTT v5 – New Opportunities For IoT Development&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>api</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>What is an API (Application Programming Interface)?</title>
      <dc:creator>Jitendra Choudhary</dc:creator>
      <pubDate>Mon, 25 Mar 2024 05:19:20 +0000</pubDate>
      <link>https://dev.to/jitendrachoudhary/what-is-an-api-5225</link>
      <guid>https://dev.to/jitendrachoudhary/what-is-an-api-5225</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;What is API?&lt;/li&gt;
&lt;li&gt;How API Works?&lt;/li&gt;
&lt;li&gt;API Protocols&lt;/li&gt;
&lt;li&gt;Types of API&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;API is really useful for the integration of new applications with existing software systems. You don't have to build everything from scratch, API provides ready-to-use functionalities for your project.&lt;/p&gt;

&lt;p&gt;A lot of times you hear the term "API" from other devs, Do you know what exactly "API" is? How it works? In this article, we'll learn about API.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftmcml5686jvqeglt927x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftmcml5686jvqeglt927x.png" alt="API Working" width="800" height="568"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is API?
&lt;/h2&gt;

&lt;p&gt;API stands for Application Protocol Interface. API is a mechanism that enables two different software components to communicate with each other which has its own set of rules and protocols.&lt;/p&gt;

&lt;p&gt;In API, one application is a client and the other is a server. Here, the client can your mobile, laptop, or computer you are using to surf the internet. The server is a bigger computer that stores the data. A protocol is nothing but a set of rules to communicate.&lt;/p&gt;

&lt;p&gt;So, let's understand this with an example: Imagine there is a vending machine in front of you. This machine can give you all sorts of drinks and snacks you need. You need to ask the machine in a specific way i.e. you select the goods you need and use a credit/debit card or maybe cash. That is kind of how an API works, but instead of snacks it delivers you the information and action on the server.&lt;/p&gt;

&lt;p&gt;But, What is an API? Well, think of it like this: you have social media, games, and even weather apps on your phone/computer. All of this does some different work. Let's say the weather app shows today's weather information. But, the app doesn't create weather information itself, It talks to a server via an API and gets back the information you requested.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcvpd1m6z8qoib6mlgmsj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcvpd1m6z8qoib6mlgmsj.png" alt="Vending Machine Example" width="800" height="568"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How API Works?
&lt;/h2&gt;

&lt;p&gt;Computers follow protocols to communicate with each other. Without a protocol, they don't have an expected form of communication.&lt;/p&gt;

&lt;p&gt;Likewise, without a protocol, you press a button to get a lemonade from the vending machine. However, the machine returns coconut water. It's all chaos, right? This is where protocol comes in, it tells you what to do step by step, like "insert money, select an item, press the button," and so on.&lt;/p&gt;

&lt;p&gt;Now, just like how vending machines have different protocols for different snacks (press A for lemonade, and B for coconut water), the internet also uses different protocols for different tasks.&lt;/p&gt;

&lt;p&gt;On the web, there is HTTP protocol (which stands for Hyper Text Markup Language). APIs on the web use the HTTP protocol because it's easy to use and it's popular. The client requests along with a set of information so the server responds accordingly. The information sent along with the request includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;URL&lt;/strong&gt; – a web address where you want to make a request&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Method&lt;/strong&gt; – whether you want data already stored somewhere or want to save new data in a database e.g. GET, POST, DELETE, PUT, etc.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Header&lt;/strong&gt; – all the relevant information about your request including in what format the client device expects to receive the data&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Body&lt;/strong&gt; – the body contains the actual requested data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fglquwalbaanovog77b01.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fglquwalbaanovog77b01.png" alt="API Architecture" width="800" height="568"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  API Protocols
&lt;/h2&gt;

&lt;p&gt;As the use of web APIs has increased, it has led to the development of certain protocols. These protocols provide users with a set of defined rules, or API specifications that create accepted data types commands, and syntax.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SOAP API (Simple Object Access Protocol)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These APIs use Simple Object Access Protocols. Client and server exchange messages using XML. This is a less flexible API that was more popular in the past.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;XML-RPC &amp;amp; JSON-RPC API (XML-Remote Procedure Call)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These APIs are called Remote Procedure Calls. The client completes a function (or procedure) on the server, and the server sends the output back to the client mainly in XML or JSON.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Websocket API&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Websocket API is another modern web API development that uses JSON objects to pass data. A WebSocket API supports two-way communication between client apps and the server. The server can send callback messages to connected clients, making it more efficient than REST API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;REST APIs&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These are the most popular and flexible APIs found on the web today. The client sends requests to the server as data. The server uses this client input to start internal functions and returns output data to the client.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of API
&lt;/h2&gt;

&lt;p&gt;Today most APIs are web APIs that expose an application's data and functionality over the internet. Here are the four main types of web API:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Open API&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Open APIs are open source application programming interfaces you can access with the HTTP protocol. Also known as public APIs, they have defined API endpoints and request and response formats.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Private API&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Private APIs remain hidden from external users. These private APIs aren't available for users outside of the company and are instead intended to improve productivity and communication across different internal development teams.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Partner API&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Partner APIs connect strategic business partners. Typically, developers access these APIs in self-service mode through a public API developer portal. Still, they need to complete an onboarding process and get login credentials to access partner APIs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Composite API&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Composite APIs combine multiple data or service APIs. They allow programmers to access several endpoints in a single call. Composite APIs are useful in microservices architecture where performing a single task may require information from several sources.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;API is nothing a mechanism for two application to communicate with certain set of information.&lt;/p&gt;

&lt;p&gt;Because APIs allow companies to open access to their resources while maintaining security and control, they have become a valuable aspect of modern business and personal projects. It is important to understand API.&lt;/p&gt;

&lt;p&gt;Interested in connecting on X? Say me Hi at &lt;a href="https://twitter.com/jiitendrac" rel="noopener noreferrer"&gt;@JitendraC&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>api</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>How to Understand a Large Codebase Like a Pro</title>
      <dc:creator>Jitendra Choudhary</dc:creator>
      <pubDate>Tue, 05 Mar 2024 12:50:28 +0000</pubDate>
      <link>https://dev.to/jitendrachoudhary/how-to-understand-a-large-codebase-like-a-pro-hmb</link>
      <guid>https://dev.to/jitendrachoudhary/how-to-understand-a-large-codebase-like-a-pro-hmb</guid>
      <description>&lt;h2&gt;
  
  
  Table of Content
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Introduction&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Read the Documentation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Read the Tests&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pair with other Engineers&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Start with the Basics&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Be Curious, Don't Criticize&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Study the Workflow&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use the Product/Service&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Conclusion&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FJ11tendra%2FNerdNarratives%2Fblob%2Fmain%2FUnderstanding-larger-codebase%2Fassets%2Fclock-time.jpg%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FJ11tendra%2FNerdNarratives%2Fblob%2Fmain%2FUnderstanding-larger-codebase%2Fassets%2Fclock-time.jpg%3Fraw%3Dtrue" alt="Anxiety by time" width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;Designed by Freepik
  &lt;/p&gt;

&lt;p&gt;Developers spend a significant amount of time on open sourced projects or institutional codebases before they push commits to production. It is a nightmare for the developers who freshly landed on the codebase. At first glance, it may be hard to understand how all the files are working together without knowing some more context. In this blog, I will share with you some of my thoughts on how to explore a legacy codebase.&lt;/p&gt;

&lt;p&gt;For the explanation part, Let's use Appwrite's codebase which is fairly big enough to threaten fresh developers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read the Documentation
&lt;/h2&gt;

&lt;p&gt;The first step I take when starting a new project is to read its documentation or README files. This allows me to get familiar with the project's setup and codebase. The documentation gives you a high-level understanding of the project's purpose, goals, and functionalities. This context helps you see how your contributions can fit into the overall picture.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FJ11tendra%2FNerdNarratives%2Fblob%2Fmain%2FUnderstanding-larger-codebase%2Fassets%2Fdocumentation.png%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FJ11tendra%2FNerdNarratives%2Fblob%2Fmain%2FUnderstanding-larger-codebase%2Fassets%2Fdocumentation.png%3Fraw%3Dtrue" alt="Appwrite Website Documentation" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;Appwrite's Website Documentation
  &lt;/p&gt;

&lt;p&gt;The documentation also provides information about the project's communication channels (e.g., forums, chatrooms) and contribution guidelines. This helps you learn how to interact with the project's community and get help when needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read the Tests
&lt;/h2&gt;

&lt;p&gt;Check for unit, integration, or functional tests in your project. Run the tests and see what each test is doing. Tests often cover not just typical scenarios but also edge cases and error conditions. By reviewing them, you gain insight into potential problems and how the code is designed to handle them. Reading the config files and others can be boring, so you don't have to understand it all at once. You can always revisit it later. That is the key. This helps you write more robust code in the future.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FJ11tendra%2FNerdNarratives%2Fblob%2Fmain%2FUnderstanding-larger-codebase%2Fassets%2Funit-tests.png%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FJ11tendra%2FNerdNarratives%2Fblob%2Fmain%2FUnderstanding-larger-codebase%2Fassets%2Funit-tests.png%3Fraw%3Dtrue" alt="Appwrite Website Repository" width="1920" height="1080"&gt;&lt;/a&gt;&lt;br&gt;Read the Tests
  &lt;/p&gt;

&lt;h2&gt;
  
  
  Pair with other Engineers
&lt;/h2&gt;

&lt;p&gt;Accessing the knowledge of an experienced developer who has already worked on the codebase can be helpful. By pairing up with this person, you can gain valuable insights into how certain things work and how to implement particular design patterns, testing, processes, and third-party code that are relevant to the project.&lt;/p&gt;

&lt;p&gt;It is important to have a good relationship with other engineers on your team and make sure they are willing to answer your questions. In turn, you should also be willing to answer questions from others. Explaining what's going on is part of your job, so don't get annoyed by questions and always treat people with respect, as they are the ones who help make you valuable to the company.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FJ11tendra%2FNerdNarratives%2Fblob%2Fmain%2FUnderstanding-larger-codebase%2Fassets%2Fpair-program.jpg%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FJ11tendra%2FNerdNarratives%2Fblob%2Fmain%2FUnderstanding-larger-codebase%2Fassets%2Fpair-program.jpg%3Fraw%3Dtrue" alt="Developers Pair Programming" width="720" height="479"&gt;&lt;/a&gt;&lt;br&gt;Designed by Freepik
  &lt;/p&gt;

&lt;h2&gt;
  
  
  Start with the Basics
&lt;/h2&gt;

&lt;p&gt;It's always a good practice to start with the basics and understand the architecture before diving into the codebase. If you intend to work with Docker, it's essential to have a good understanding of container technology. Similarly, if you plan to work with service implementation, it's crucial to understand the fundamentals of service-oriented architecture. If you find it challenging to understand the code, take a step back and check if you're missing any basic information. If you're having difficulty understanding the code, it may be because you lack the necessary knowledge.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FJ11tendra%2FNerdNarratives%2Fblob%2Fmain%2FUnderstanding-larger-codebase%2Fassets%2Fbasic-architecture.png%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FJ11tendra%2FNerdNarratives%2Fblob%2Fmain%2FUnderstanding-larger-codebase%2Fassets%2Fbasic-architecture.png%3Fraw%3Dtrue" alt="Appwrite's Website" width="1920" height="1080"&gt;&lt;/a&gt;&lt;br&gt;Understand Basic Architecture
  &lt;/p&gt;

&lt;h2&gt;
  
  
  Be Curious, Don't Criticize
&lt;/h2&gt;

&lt;p&gt;When you're dealing with legacy code, it's important to remember that it was written by experienced developers who made decisions based on the context at the time. Criticizing it can make people feel attacked and can hurt collaboration. Instead, approach it with empathy and ask questions to understand the thought process behind it. This can help you learn from past mistakes and get insights into the project's evolution. By doing this, you can cultivate a learning mindset and promote collaboration, which is critical to the success of any project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FJ11tendra%2FNerdNarratives%2Fblob%2Fmain%2FUnderstanding-larger-codebase%2Fassets%2Fcurious.jpg%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FJ11tendra%2FNerdNarratives%2Fblob%2Fmain%2FUnderstanding-larger-codebase%2Fassets%2Fcurious.jpg%3Fraw%3Dtrue" alt="Curious Developer" width="760" height="506"&gt;&lt;/a&gt;&lt;br&gt;Designed by Freepik
  &lt;/p&gt;

&lt;h2&gt;
  
  
  Study the Workflow
&lt;/h2&gt;

&lt;p&gt;Take your time to understand the workflow of the most crucial parts of the codebase. It's essential to learn how different components connect. By tracing the flow of operations within a codebase, you can gain a better understanding of how everything works. This experience will help you act with precision when implementing features or fixing bugs within the codebase.&lt;/p&gt;

&lt;p&gt;If you're unsure about how to get started, begin with a function. Read it carefully, then proceed to read and comprehend other functions or components that use it. You can repeat this process with modules, classes, and others until you have a solid understanding of the codebase.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FJ11tendra%2FNerdNarratives%2Fblob%2Fmain%2FUnderstanding-larger-codebase%2Fassets%2Fworkflow.jpg%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FJ11tendra%2FNerdNarratives%2Fblob%2Fmain%2FUnderstanding-larger-codebase%2Fassets%2Fworkflow.jpg%3Fraw%3Dtrue" alt="Developer's Workflow" width="760" height="506"&gt;&lt;/a&gt;&lt;br&gt;Designed by Freepik
  &lt;/p&gt;

&lt;h2&gt;
  
  
  Use the Product/Service
&lt;/h2&gt;

&lt;p&gt;Before you start writing code, try to explore the platform like what it does. why it does? for whom it does? how fast it does?&lt;/p&gt;

&lt;p&gt;Developers (You) write code for users to use the product and if you don't put yourself in the user's shoes you never know what the user might feel about a certain aspect of the platform. So, put yourself into the end user's shoes and understand what it is like to use the product. By having a good understanding of customers' needs, you can contribute features that end users will love.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FJ11tendra%2FNerdNarratives%2Fblob%2Fmain%2FUnderstanding-larger-codebase%2Fassets%2Fuse-platform.png%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FJ11tendra%2FNerdNarratives%2Fblob%2Fmain%2FUnderstanding-larger-codebase%2Fassets%2Fuse-platform.png%3Fraw%3Dtrue" alt="Appwrite's Website" width="1920" height="1080"&gt;&lt;/a&gt;&lt;br&gt;Appwrite's Website
  &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Having a strong understanding of a codebase can greatly increase your efficiency when working with a new codebase. By efficiently comprehending code written by other developers, you can improve your impact and productivity within an organization. This can be achieved by dedicating some extra time and patience towards learning the codebase.&lt;/p&gt;

&lt;p&gt;Did you find the tips on how to navigate a new codebase useful? Here's how you can stay connected and continue learning. You can follow me &lt;a href="https://twitter.com/JiitendraC" rel="noopener noreferrer"&gt;@JitendraC&lt;/a&gt; on Twitter, where I regularly tweet about software development tips, industry trends, and fascinating projects. If you know someone who could benefit from these insights, share this article with them on Twitter! Let's assist more developers in conquering complex codebases together.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>productivity</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
