<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by PavanBhakta on Medium]]></title>
        <description><![CDATA[Stories by PavanBhakta on Medium]]></description>
        <link>https://medium.com/@bPavan16?source=rss-47da65da6428------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*7QCznuUDHJYIS74Ze1j5hg.jpeg</url>
            <title>Stories by PavanBhakta on Medium</title>
            <link>https://medium.com/@bPavan16?source=rss-47da65da6428------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 12 Nov 2026 02:06:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bPavan16/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Understanding the Playfair Cipher with Python]]></title>
            <link>https://medium.com/@bPavan16/understanding-the-playfair-cipher-with-python-13caacc25d75?source=rss-47da65da6428------2</link>
            <guid isPermaLink="false">https://medium.com/p/13caacc25d75</guid>
            <category><![CDATA[encoding]]></category>
            <category><![CDATA[cipher]]></category>
            <dc:creator><![CDATA[PavanBhakta]]></dc:creator>
            <pubDate>Mon, 18 Aug 2025 12:26:48 GMT</pubDate>
            <atom:updated>2025-08-18T12:26:48.468Z</atom:updated>
            <content:encoded><![CDATA[<p>Cryptography is all about keeping secrets safe. Today, we’ll learn one of the most famous classical ciphers: the <strong>Playfair Cipher</strong>.<br> It was used in wars and espionage because it was much stronger than simple substitution ciphers.</p><p>We’ll go step by step first understanding the <strong>concept</strong>, then looking at the <strong>Python code implementation</strong></p><h3>What is the Playfair Cipher?</h3><p>The <strong>Playfair Cipher</strong> is a substitution cipher, but instead of replacing single letters like Caesar Cipher, it works with <strong>pairs of letters (digraphs)</strong>.</p><p>This small change makes it much harder to break because:</p><ul><li>There are 26 letters, so a simple cipher has 26 possibilities.</li><li>But with pairs, there are <strong>26 × 26 = 676 possible combinations!</strong></li></ul><p>Playfair was a big upgrade back in the 1800s.</p><h3>Step 1: Creating the Playfair Square</h3><p>The Playfair Cipher uses a <strong>5x5 grid of letters</strong> (25 slots total).<br> Since the English alphabet has 26 letters, the letters I and J are considered the same.</p><h4><strong>How the square is built:</strong></h4><ol><li>Choose a secret key (word or phrase).</li><li>Write the key into the grid (ignoring duplicates).</li><li>Fill in the remaining letters of the alphabet.</li></ol><p>👉 Example with key = <strong>“MONARCHY”</strong></p><pre>M O N A R<br>C H Y B D<br>E F G I K<br>L P Q S T<br>U V W X Z</pre><ul><li>The key letters (M, O, N, A, R, C, H, Y) come first.</li><li>Then we add the rest of the alphabet, skipping duplicates.</li><li>I and J are merged (so only one appears).</li></ul><p>This grid is the <strong>main part of the Playfair cipher</strong>. Both sender and receiver need the same key to encrypt and decrypt.</p><h3>Step 2: Preparing the Message</h3><p>Before encrypting, the plaintext must be cleaned and split into <strong>pairs of letters</strong>.</p><h4>Rules:</h4><ol><li>Remove spaces, punctuation, and numbers.</li><li>Convert everything to uppercase</li><li>Replace J with I.</li><li>Split into pairs (digraphs).</li><li>If both letters in a pair are the same, insert an X in between.</li><li>If there’s an odd number of letters, add an X at the end.</li></ol><h4>Example 1:</h4><p>👉 Example with plaintext = <strong>“ATTACK”</strong></p><ol><li>Clean: ATTACK → ATTACK</li><li>Pairs: AT TA CK</li><li>No duplicates inside pairs → valid</li><li>Length is even → no padding needed</li></ol><p>Final digraphs: <strong>AT | TA | CK</strong></p><h4>Example 2:</h4><p>Another example: plaintext = <strong>“BALLOON”</strong></p><ul><li>Clean: BALLOON</li><li>Pairs: BA LL OO N</li><li>Adjust duplicates: BA LX LO ONX<br> Final digraphs: <strong>BA | LX | LO | ON | X</strong></li></ul><h3>Step 3: Encryption Rules</h3><p>Now comes the fun part! Each pair of letters is encrypted using the <strong>Playfair Square</strong>.</p><p>Let’s say we’re encrypting the digraph (A, T).</p><p>There are <strong>three possible cases</strong>:</p><h4>Rule 1: Same Row</h4><p>If both letters are in the <strong>same row</strong>, replace each with the letter <strong>to its right</strong> (wrap around if needed).</p><p>Example: (A, R) in row 1:</p><pre>M O N A R</pre><ul><li>A → R (right of A)</li><li>R → M (wrap around)<br> Encrypted: RM</li></ul><h4>Rule 2: Same Column</h4><p>If both letters are in the <strong>same column</strong>, replace each with the letter <strong>below it</strong> (wrap around if needed).</p><p>Example: (M, C) in column 1:</p><pre>M<br>C<br>E<br>L<br>U</pre><ul><li>M → C</li><li>C → E<br> Encrypted: CE</li></ul><h4>Rule 3: Rectangle Rule</h4><p>If the letters form the <strong>corners of a rectangle</strong>, replace each with the letter <strong>in the same row but in the other column</strong>.</p><p>Example: (A, T)</p><pre>M O N A R<br>L P Q S T</pre><ul><li>A (row 1, col 4) → T (row 1, col 5)</li><li>T (row 4, col 5) → S (row 4, col 4)<br> Encrypted: TS</li></ul><h4>Step 4: Decryption Rules</h4><p>Decryption is just the reverse:</p><ol><li><strong>Same row:</strong> Replace with the letter <strong>to the left</strong>.</li><li><strong>Same column:</strong> Replace with the letter <strong>above</strong>.</li><li><strong>Rectangle:</strong> Swap corners again.</li></ol><p>Padding Xs are removed at the end if they were artificially added.</p><h3>Python Implementation</h3><p>Let’s now look at the code and understand it step by step.</p><h3>1. Generating the Playfair Square</h3><pre>def generate_playfair_square(key):<br>    key = &quot;&quot;.join([c.upper() for c in key if c.isalpha()])<br>    key = key.replace(&quot;J&quot;, &quot;I&quot;)<br>    seen = set()<br>    square = []<br>    for c in key + string.ascii_uppercase:<br>        if c not in seen and c != &quot;J&quot;:<br>            seen.add(c)<br>            square.append(c)<br>    return [square[i * 5 : (i + 1) * 5] for i in range(5)]</pre><p>This function:</p><ul><li>Cleans the key (removes non-letters, converts to uppercase, replaces J with I).</li><li>Fills a 5x5 matrix with unique letters.</li><li>Returns the matrix (Playfair square).</li></ul><h3>2. Preparing the Text</h3><pre>def prepare_text(text, for_encrypt=True):<br>    text = &quot;&quot;.join([c.upper() for c in text if c.isalpha()])<br>    text = text.replace(&quot;J&quot;, &quot;I&quot;)<br>    result = &quot;&quot;<br>    i = 0<br>    while i &lt; len(text):<br>        a = text[i]<br>        b = text[i + 1] if i + 1 &lt; len(text) else &quot;X&quot;<br>        if a == b:<br>            result += a + &quot;X&quot;<br>            i += 1<br>        else:<br>            result += a + b<br>            i += 2<br>    if len(result) % 2 != 0:<br>        result += &quot;X&quot;<br>    return result</pre><p>This ensures:</p><ul><li>Only letters are kept.</li><li>Pairs are formed properly.</li><li>Same letters in a pair are separated by X.</li><li>Odd length words get padded with X.</li></ul><p>Example:<br> ATTACK → AT TA CK (already valid)</p><h3>3. Finding Letter Positions</h3><pre>def find_position(square, char):<br>    for i, row in enumerate(square):<br>        if char in row:<br>            return i, row.index(char)<br>    return None</pre><p>👉 Returns the row and column of a character in the Playfair square.</p><h3>4. Encrypting the Message</h3><pre>def playfair_encrypt(plaintext, key):<br>    square = generate_playfair_square(key)<br>    text = prepare_text(plaintext)<br>    result = &quot;&quot;<br>    for i in range(0, len(text), 2):<br>        a, b = text[i], text[i + 1]<br>        r1, c1 = find_position(square, a)<br>        r2, c2 = find_position(square, b)<br>        if r1 == r2:  # same row<br>            result += square[r1][(c1 + 1) % 5] + square[r2][(c2 + 1) % 5]<br>        elif c1 == c2:  # same column<br>            result += square[(r1 + 1) % 5][c1] + square[(r2 + 1) % 5][c2]<br>        else:  # rectangle rule<br>            result += square[r1][c2] + square[r2][c1]<br>    return result</pre><p>👉 This applies the Playfair rules we discussed.</p><h3>5. Decrypting the Message</h3><pre>def playfair_decrypt(ciphertext, key):<br>    square = generate_playfair_square(key)<br>    result = &quot;&quot;<br>    for i in range(0, len(ciphertext), 2):<br>        a, b = ciphertext[i], ciphertext[i + 1]<br>        r1, c1 = find_position(square, a)<br>        r2, c2 = find_position(square, b)<br>        if r1 == r2:  # same row<br>            result += square[r1][(c1 - 1) % 5] + square[r2][(c2 - 1) % 5]<br>        elif c1 == c2:  # same column<br>            result += square[(r1 - 1) % 5][c1] + square[(r2 - 1) % 5][c2]<br>        else:  # rectangle rule<br>            result += square[r1][c2] + square[r2][c1]<br>    return result</pre><p>👉 Same logic, but reversed.</p><h3>6. Running the Program</h3><pre>if __name__ == &quot;__main__&quot;:<br>    key = &quot;MONARCHY&quot;<br>    plaintext = &quot;ATTACK&quot;<br><br>encrypted = playfair_encrypt(plaintext, key)<br>    decrypted = playfair_decrypt(encrypted, key)<br>    print(f&quot;Key : {key}&quot;)<br>    print(f&quot;Plaintext : {plaintext}&quot;)<br>    print(&quot;Encrypted:&quot;, encrypted)<br>    print(&quot;Decrypted:&quot;, decrypted)</pre><p>💡 Example Output:</p><pre>Key : MONARCHY<br>Plaintext : ATTACK<br>Encrypted: RRFVSZ<br>Decrypted: ATTACKX</pre><p>Notice how the decrypted text has an extra X. That’s because of the padding rule we discussed.</p><h4>Why Learn Playfair Today?</h4><p>Even though the Playfair Cipher is <strong>not secure by modern standards</strong>, it’s still important because:</p><ul><li>It introduces concepts like <strong>substitution</strong>, <strong>digraphs</strong>, and <strong>key-based encryption</strong>.</li><li>It shows how historical cryptography worked before computers.</li><li>It’s a great way to practice coding algorithms step by step.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13caacc25d75" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chapter 7 : Conditional Rendering Showing the Right Things at the Right Time]]></title>
            <link>https://javascript.plainenglish.io/chapter-7-conditional-rendering-showing-the-right-things-at-the-right-time-bf8341344dae?source=rss-47da65da6428------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf8341344dae</guid>
            <category><![CDATA[ssfu-course]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[ssfu-react-course]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[PavanBhakta]]></dc:creator>
            <pubDate>Thu, 31 Jul 2025 05:01:57 GMT</pubDate>
            <atom:updated>2025-08-03T00:28:37.795Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Chapter 7 : Conditional Rendering Showing the Right Things at the Right Time</strong></h3><h3>Previously in Our React Series . . .</h3><ul><li>Learned JSX (like writing HTML in JavaScript) Created your first reusable components</li><li>Passed props between components Handled user events (remember that clickable counter?)</li></ul><p>Now, imagine this:</p><ul><li>What if the user is <strong>logged in</strong>?</li><li>What if they have <strong>no notifications</strong>?</li><li>What if they <strong>clicked a button</strong>?</li></ul><p>You guessed it. This is where <strong>Conditional Rendering</strong> comes in. Let’s break it down, step-by-step.</p><h3>What is Conditional Rendering?</h3><p>Conditional rendering is how your app <strong>decides what to show</strong> and what <strong>not to show</strong>, based on <strong>certain conditions</strong>.</p><p>It’s like your app is asking: <em>“Should I show this? Yes or no?”</em></p><p>Just like if statements in JavaScript — but now inside your React components.</p><h3>Basic Example with if-else</h3><pre>function WelcomeMessage({ isLoggedIn }) {<br>    if (isLoggedIn) {<br>        return &lt;h2&gt;Welcome back, Pavan!&lt;/h2&gt;;<br>    } else {<br>        return &lt;h2&gt;Please log in to continue.&lt;/h2&gt;;<br>    }<br>}</pre><h3>What’s happening:</h3><ul><li>We’re checking if the user is logged in.</li><li>Based on that, we return <strong>different JSX</strong>.</li></ul><p>Simple and clean, right?</p><h3>Shorter Version: Ternary Operator</h3><pre>function WelcomeMessage({ isLoggedIn }) {<br>    return (<br>        &lt;h2&gt;{isLoggedIn ? &quot;Welcome back!&quot; : &quot;Please log in.&quot;}&lt;/h2&gt;<br>    );<br>}</pre><h4>Syntax:</h4><p>condition ? show this : show that</p><p>It’s like a mini if-else on one line.</p><h3>Show Only If True (Using &amp;&amp;)</h3><p>Sometimes, you only want to show something <strong>if</strong> a condition is true, and <strong>hide it completely</strong> otherwise.</p><pre>function Notification({ hasMessage }) {<br>    return (<br>        &lt;div&gt;<br>            {hasMessage &amp;&amp; &lt;p&gt;You have a new message!&lt;/p&gt;}<br>        &lt;/div&gt;<br>    );<br>}</pre><p>If hasMessage is false, React won’t render anything — not even empty space. That’s the magic of &amp;&amp;.</p><h4>Pro Tip: Avoid Too Much Logic in JSX</h4><pre>// Not great for readability<br>{isLoggedIn &amp;&amp; age &gt; 18 &amp;&amp; user.hasPermission &amp;&amp; &lt;SecretPanel /&gt;}</pre><p>Better:</p><pre>const canAccess = isLoggedIn &amp;&amp; age &gt; 18 &amp;&amp; user.hasPermission;</pre><pre>return canAccess &amp;&amp; &lt;SecretPanel /&gt;;</pre><p>Keep it clean. Your future self will thank you.</p><h3>Mini Project: Show/Hide Password Feature</h3><p>Let’s use everything we’ve learned to build a real feature — one you see in almost every login form.</p><h3>What we’re building:</h3><ul><li>A password input field</li><li>A checkbox to <strong>toggle visibility</strong> of the password</li></ul><h3>Why It’s Cool:</h3><ul><li>Uses <strong>state</strong> with useState</li><li>Uses <strong>event handling</strong></li><li>Uses <strong>conditional rendering</strong> to switch input types</li></ul><h4>Final Code:</h4><pre>import React, { useState } from &#39;react&#39;;</pre><pre>function PasswordToggle() {<br>    const [showPassword, setShowPassword] = useState(false);<br>    const handleCheckboxChange = () =&gt; {<br>        setShowPassword(prev =&gt; !prev);<br>    };<br>    <br>return (<br>        &lt;div style={{ maxWidth: &#39;300px&#39;, margin: &#39;auto&#39;, padding: &#39;20px&#39;, border: &#39;1px solid #ccc&#39;, borderRadius: &#39;8px&#39; }}&gt;<br>            &lt;h2&gt;Password Input&lt;/h2&gt;<br>            &lt;input <br>                type={showPassword ? &#39;text&#39; : &#39;password&#39;} <br>                placeholder=&quot;Enter your password&quot;<br>                style={{ width: &#39;100%&#39;, padding: &#39;10px&#39;, fontSize: &#39;16px&#39;, marginBottom: &#39;10px&#39; }}<br>            /&gt;<br>            &lt;div&gt;<br>                &lt;label&gt;<br>                    &lt;input <br>                        type=&quot;checkbox&quot; <br>                        checked={showPassword} <br>                        onChange={handleCheckboxChange}<br>                    /&gt; Show Password<br>                &lt;/label&gt;<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br>    );<br>}<br>export default PasswordToggle;</pre><h3>What’s Happening:</h3><ul><li>We use useState(false) to track whether the password is shown or hidden.</li><li>Based on that, we <strong>conditionally render</strong> the input type: text or password.</li><li>The checkbox toggles the state.</li></ul><p>You’ve just built a real, user-friendly feature.</p><h3>Summary : Here’s what you learned today</h3><ul><li>How to show/hide UI parts with:</li><li>if-else</li><li>Ternary (? :)</li><li>&amp;&amp;</li><li>How to cleanly organize your logic</li><li>How to apply it all in a <strong>mini project</strong></li></ul><h3>What’s Next?</h3><p><strong>Rendering Lists in React — Mapping Your Way to Dynamic UIs</strong></p><p>Real apps deal with <strong>lots of data</strong>: to-do lists, messages, users, posts…<br>So let’s learn how to loop through arrays and render multiple components dynamically.</p><h3>Thank you for being a part of the community</h3><p><em>Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏️<strong>️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/@InPlainEnglish"><strong>YouTube</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a> | <a href="https://twitch.tv/inplainenglish"><strong>Twitch</strong></a></li><li><a href="https://differ.blog/"><strong>Start your own free AI-powered blog on Differ</strong></a> 🚀</li><li><a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Join our content creators community on Discord</strong></a> 🧑🏻‍💻</li><li>For more content, visit <a href="https://plainenglish.io/"><strong>plainenglish.io</strong></a> + <a href="https://stackademic.com/"><strong>stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf8341344dae" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/chapter-7-conditional-rendering-showing-the-right-things-at-the-right-time-bf8341344dae">Chapter 7 : Conditional Rendering Showing the Right Things at the Right Time</a> was originally published in <a href="https://javascript.plainenglish.io">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chapter 4: Understanding Props and How Components Talk to Each Other]]></title>
            <link>https://javascript.plainenglish.io/chapter-4-understanding-props-and-how-components-talk-to-each-other-7056931607d2?source=rss-47da65da6428------2</link>
            <guid isPermaLink="false">https://medium.com/p/7056931607d2</guid>
            <category><![CDATA[ssfu-course]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[ssfu-react-course]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[PavanBhakta]]></dc:creator>
            <pubDate>Thu, 31 Jul 2025 03:59:00 GMT</pubDate>
            <atom:updated>2025-08-03T00:28:33.372Z</atom:updated>
            <content:encoded><![CDATA[<h3>“Props” is just a fancy word for passing data and its very easy</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*7q3s44U7fhI0r9mELLwnqA.png" /></figure><h3>Previously, on React 101…</h3><p>You learned how to create your <strong>first React component</strong> and how JSX works like magic — mixing HTML and JavaScript into one smooth experience.</p><p>Now let’s go one step further and learn how to <strong>pass data between components</strong> using <strong>props</strong>.</p><h3>What Are Props?</h3><p><strong>Props</strong> (short for <strong>properties</strong>) are how components <strong>receive data</strong> from other components.</p><p>Think of it like this:<br>If a component is a <strong>function</strong>, props are the <strong>parameters</strong> you pass into it.</p><h3>Analogy:</h3><p>Imagine you’re giving a gift box (component) to a friend.<br>The items inside the box? Those are the <strong>props</strong> — the data you’re handing over.</p><h3>A Real Example</h3><p>Let’s say you have a component that displays a greeting.</p><h4>Greeting.js:</h4><pre>function Greeting(props) {<br>    return &lt;h1&gt;Hello, {props.name}&lt;/h1&gt;;<br>}<br><br>export default Greeting;</pre><p>Here, props.name is the data we’re passing <strong>into</strong> the component.</p><h4>Now in App.js:</h4><pre>import Greeting from &#39;./Greeting&#39;;<br><br>function App() {<br>    return (<br>        &lt;div&gt;<br>            &lt;Greeting name=&quot;Pavan&quot; /&gt;<br>            &lt;Greeting name=&quot;Maya&quot; /&gt;<br>        &lt;/div&gt;<br>    );<br>}</pre><p>When you run this, it shows:</p><pre>Hello, Pavan  <br>Hello, Maya</pre><p><strong>Boom!</strong> Components are now talking to each other — and you’re passing dynamic data.</p><h3>Let’s Break It Down</h3><pre>&lt;Greeting name=&quot;Pavan&quot; /&gt;</pre><ul><li>This is how we <strong>pass a prop</strong></li><li>name=&quot;Pavan&quot; is a <strong>prop</strong> being sent to the Greeting component</li></ul><pre>function Greeting(props) {</pre><ul><li>This is how we <strong>receive</strong> the prop in the component</li></ul><pre>{props.name}</pre><ul><li>This is how we <strong>use</strong> it inside JSX</li></ul><h3>Cleaner with Destructuring</h3><p>Instead of writing props.name, we can use JavaScript destructuring to make it cleaner:</p><pre>function Greeting({ name }) {<br>    return &lt;h1&gt;Hello, {name}&lt;/h1&gt;;<br>}</pre><p>Same output. Less typing. Win-win.</p><h3>You Can Pass More Than Just Text</h3><p>Props can be <strong>numbers, booleans, arrays, objects, or even functions</strong>!</p><h3>Example:</h3><pre>function UserCard({ name, age }) {<br>    return (<br>        &lt;div&gt;<br>            &lt;h2&gt;{name}&lt;/h2&gt;<br>            &lt;p&gt;Age: {age}&lt;/p&gt;<br>        &lt;/div&gt;<br>    );<br>}<br><br>function App() {<br>    return &lt;UserCard name=&quot;Pavan&quot; age={21} /&gt;;<br>}</pre><h3>Try This: Create a QuoteCard Component</h3><h4>QuoteCard.js:</h4><pre>function QuoteCard({ quote, author }) {<br>    return (<br>        &lt;div className=&quot;quote&quot;&gt;<br>            &lt;p&gt;&quot;{quote}&quot;&lt;/p&gt;<br>            &lt;small&gt;- {author}&lt;/small&gt;<br>        &lt;/div&gt;<br>    );<br>}<br><br>export default QuoteCard;</pre><h4>Use it in App.js:</h4><pre>&lt;QuoteCard<br>    quote=&quot;First, solve the problem. Then, write the code.&quot;<br>    author=&quot;John Johnson&quot;<br>/&gt;</pre><p>This is how React lets you <strong>reuse components</strong> and change their behavior based on the <strong>props</strong> you pass.</p><h3>A Few Props Gotchas</h3><ul><li>Props are <strong>read-only</strong>. You <strong>can’t change</strong> them inside the child component.</li><li>Props must be passed from <strong>parent → child</strong>, not the other way around.</li><li>If you forget to pass a prop, React won’t crash — it’ll just show undefined.</li></ul><h3>Recap</h3><ul><li>Props are <strong>how components talk</strong> to each other.</li><li>You <strong>pass props</strong> like HTML attributes.</li><li>Inside the component, you use props.propName (or destructure).</li><li>Props make components <strong>reusable and dynamic</strong>.</li></ul><h3>Up Next: Make Your Components Smart with useState</h3><p>Props let you pass <strong>data in</strong>. But what if you want components to <strong>store and manage their own data</strong> — like a counter or a to-do list?</p><p>That’s where <strong>useState</strong> comes in.</p><p>In the next blog: <strong>“React’s useState Hook: Giving Memory to Your Components”</strong></p><h3>Got Questions?</h3><p>Drop them in the comments or hit me up — there’s no such thing as a silly question here!</p><h3>Thank you for being a part of the community</h3><p><em>Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏️<strong>️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/@InPlainEnglish"><strong>YouTube</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a> | <a href="https://twitch.tv/inplainenglish"><strong>Twitch</strong></a></li><li><a href="https://differ.blog/"><strong>Start your own free AI-powered blog on Differ</strong></a> 🚀</li><li><a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Join our content creators community on Discord</strong></a> 🧑🏻‍💻</li><li>For more content, visit <a href="https://plainenglish.io/"><strong>plainenglish.io</strong></a> + <a href="https://stackademic.com/"><strong>stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7056931607d2" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/chapter-4-understanding-props-and-how-components-talk-to-each-other-7056931607d2">Chapter 4: Understanding Props and How Components Talk to Each Other</a> was originally published in <a href="https://javascript.plainenglish.io">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chapter 3 : Understanding JSX & Building Your First React Component]]></title>
            <link>https://javascript.plainenglish.io/chapter-3-understanding-jsx-building-your-first-react-component-0ee8ea825c23?source=rss-47da65da6428------2</link>
            <guid isPermaLink="false">https://medium.com/p/0ee8ea825c23</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ssfu-course]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[ssfu-react-course]]></category>
            <dc:creator><![CDATA[PavanBhakta]]></dc:creator>
            <pubDate>Sat, 26 Jul 2025 14:13:26 GMT</pubDate>
            <atom:updated>2025-08-03T00:28:16.942Z</atom:updated>
            <content:encoded><![CDATA[<h3>Chapter 3 : Understanding JSX &amp; Building Your First React Component</h3><h3>Previously, on this Course</h3><p>So far in this series, we’ve:</p><ul><li>Learned what React is (spoiler: it’s awesome)</li><li>Set up our environment with Create React App or Vite</li></ul><p>Now it’s time to build something!</p><p>But before we do, let’s talk about <strong>JSX</strong> — the secret sauce that makes React so cool — and then write our <strong>very first React component</strong> together.</p><h3>What is JSX?</h3><p>JSX stands for <strong>JavaScript XML</strong>.</p><p>Sounds scary? Don’t worry — it’s actually pretty simple.</p><p>Here’s the deal:</p><p><em>JSX lets you </em><strong><em>write HTML-like code inside your JavaScript</em></strong><em>.</em></p><p>Yes, you read that right. In React, you can write this:</p><pre>const element = &lt;h1&gt;Hello, React!&lt;/h1&gt;;</pre><p>Looks like HTML, right? But that’s actually JavaScript under the hood.</p><h3>🤔 Why not just use HTML?</h3><p>Because you want the <strong>power of JavaScript</strong> <em>and</em> the <strong>structure of HTML</strong> — in one place.</p><p>JSX combines both. It’s like the best of both worlds.</p><h3>Let’s take a deeper look at how JSX works:</h3><h4>It looks like HTML</h4><pre>&lt;h1&gt;Hello, World!&lt;/h1&gt;</pre><h4>But you can embed JavaScript inside it</h4><pre>const name = &quot;Pavan&quot;;<br>&lt;h1&gt;Hello, {name}!&lt;/h1&gt;</pre><p>Yes, the curly braces {} let you <strong>run JavaScript</strong> inside your HTML-like JSX.</p><p>You can do things like:</p><pre>const age = 21;<br>&lt;p&gt;I am {age &gt;= 18 ? &#39;an adult&#39; : &#39;a kid&#39;}.&lt;/p&gt;</pre><h3>Important JSX Rules</h3><ol><li><strong>Return only one parent element</strong><br> This is wrong:</li></ol><pre>return (<br>  &lt;h1&gt;Hello&lt;/h1&gt;<br>  &lt;p&gt;World&lt;/p&gt;<br>);</pre><p>This is right:</p><pre>return (<br>  &lt;div&gt;<br>    &lt;h1&gt;Hello&lt;/h1&gt;<br>    &lt;p&gt;World&lt;/p&gt;<br>  &lt;/div&gt;<br>);</pre><p>Use a wrapper like &lt;div&gt; or React Fragment (&lt;&gt; &lt;/&gt;) to group elements.</p><p><strong>2. Use </strong><strong>className instead of </strong><strong>class</strong><br> Why? Because class is a reserved word in JavaScript.</p><pre>&lt;div className=&quot;container&quot;&gt;This works&lt;/div&gt;</pre><h3>Let’s Build Your First React Component!</h3><h3>What’s a Component?</h3><p>A <strong>component</strong> is a reusable block of UI.</p><p>Think of it like a LEGO piece. You build a few of them, and then piece them together to build your whole app.</p><h3>Step-by-Step: Create a Simple Component</h3><p>Open App.js inside your React project and replace its content with this:</p><pre>import React from &#39;react&#39;;function Greeting() {<br> <br>const name = &quot;Pavan&quot;;<br><br>return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Hello, {name} &lt;/h1&gt;<br>      &lt;p&gt;Welcome to your first React component!&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>}<br>export default Greeting;</pre><h3>Then update index.js to use it:</h3><pre>import React from &#39;react&#39;;<br>import ReactDOM from &#39;react-dom/client&#39;;<br>import Greeting from &#39;./App&#39;;  // importing the component<br><br>const root = ReactDOM.createRoot(document.getElementById(&#39;root&#39;));<br>root.render(&lt;Greeting /&gt;);</pre><p>Open the browser :</p><blockquote><strong><em>Hello, Pavan </em></strong><em><br> Welcome to your first React component!</em></blockquote><p>Congrats you just built your first React component!</p><h3>Let’s Break It Down</h3><pre>function Greeting() {<br><br>}</pre><p>This is a <strong>functional component</strong> — the most common type in modern React.</p><pre>const name = &quot;Pavan&quot;;</pre><p>Regular JavaScript variable.</p><pre>&lt;h1&gt;Hello, {name} &lt;/h1&gt;</pre><p>This is JSX in action. We’re mixing JavaScript inside what looks like HTML.</p><pre>export default Greeting;</pre><p>This lets us <strong>use the component elsewhere</strong> in our app — like a puzzle piece.</p><h3>Try This Mini Challenge</h3><p>Want to practice?</p><p>Add another component called Quote that displays a quote of the day.</p><pre>function Quote() {<br>  return (<br>    &lt;blockquote&gt;<br>      “First, solve the problem. Then, write the code.” – John Johnson<br>    &lt;/blockquote&gt;<br>  );<br>}</pre><p>Then import and use it inside your Greeting component like this:</p><pre>&lt;Quote /&gt;</pre><p>That’s <strong>component composition</strong> — building UIs like stacking bricks!</p><h3>In a Nutshell</h3><ul><li>JSX lets you write HTML inside JavaScript</li><li>Curly braces {} let you use variables and logic inside JSX</li><li>Components are the heart of every React app</li><li>You just built your first real component!</li></ul><p>Congrats! You now understand what JSX is and how to build your first React component the building blocks of every React app. With this foundation, you’re ready to start passing data between components and making your UI truly dynamic</p><h3><strong>Next Up -</strong></h3><p><strong>Let’s Dive Into Props: How React Components Talk to Each Other and Share Data</strong></p><h3>Thank you for being a part of the community</h3><p><em>Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏️<strong>️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/@InPlainEnglish"><strong>YouTube</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a> | <a href="https://twitch.tv/inplainenglish"><strong>Twitch</strong></a></li><li><a href="https://differ.blog/"><strong>Start your own free AI-powered blog on Differ</strong></a> 🚀</li><li><a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Join our content creators community on Discord</strong></a> 🧑🏻‍💻</li><li>For more content, visit <a href="https://plainenglish.io/"><strong>plainenglish.io</strong></a> + <a href="https://stackademic.com/"><strong>stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0ee8ea825c23" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/chapter-3-understanding-jsx-building-your-first-react-component-0ee8ea825c23">Chapter 3 : Understanding JSX &amp; Building Your First React Component</a> was originally published in <a href="https://javascript.plainenglish.io">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chapter 2 : Setting Up React the Easy Way, No Headaches, Just Code]]></title>
            <link>https://javascript.plainenglish.io/chapter-2-setting-up-react-the-easy-way-no-headaches-just-code-e386c2b4fb96?source=rss-47da65da6428------2</link>
            <guid isPermaLink="false">https://medium.com/p/e386c2b4fb96</guid>
            <category><![CDATA[ssfu-react-course]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[PavanBhakta]]></dc:creator>
            <pubDate>Fri, 25 Jul 2025 16:56:08 GMT</pubDate>
            <atom:updated>2025-08-03T00:28:09.092Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Chapter 2 : Setting Up React the Easy Way, No Headaches, Just Code</strong></h3><p><em>You’ve heard the hype about React. You know it’s powering big names like Netflix and Instagram. Now it’s time to build something yourself.</em></p><p>But wait… where do you even start?</p><p>Don’t worry this post is your step-by-step guide to setting up your very first React project.</p><p>No experience? No problem. Let’s do this together.</p><h3>1. Before We Begin What Do You Need?</h3><p>To build React apps, you’ll need two things:</p><h4>Node.js</h4><p>Think of it as the engine that runs your JavaScript code outside the browser.</p><h4>npm (Node Package Manager)</h4><p>It helps you install useful tools and libraries like React!</p><h3>2. Install Node.js and npm (One-Time Setup)</h3><p>Follow these steps:</p><ol><li>Go to <a href="https://nodejs.org/">https://nodejs.org</a></li><li>Download the <strong>LTS version</strong> (it’s the stable one)</li><li>Install it just like any other app</li></ol><h3>To make sure it worked:</h3><p>Open your <strong>terminal</strong> or <strong>Command Prompt</strong> and run:</p><pre>node -v<br>npm -v</pre><p>If you see version numbers, you’re good to go!</p><h3>3. Creating Your First React App (Using CRA)</h3><p>React gives you a tool called <strong>Create React App</strong> (CRA) that sets up everything for you.</p><p>It’s like ordering a pizza with all toppings no need to make the dough from scratch.</p><h4>Steps:</h4><ol><li>Open your terminal</li><li>Run:</li></ol><pre>npx create-react-app my-first-app</pre><p>npx runs the command without installing it globally<br>create-react-app sets up your entire React project<br>my-first-app is the folder name for your project</p><p>This may take a couple of minutes grab a chai or coffee.</p><h4>Start the app:</h4><p>Once it’s done, run:</p><pre>cd my-first-app<br>npm start</pre><p>Your default browser should open up with a page that says:</p><p><strong>“Edit </strong><strong>src/App.js and save to reload.&quot;</strong></p><p>Boom. You’ve just created your first React app!</p><h3>4. Understanding the Project Structure</h3><p>Let’s peek inside the project folder.</p><p>Here are the 3 files you’ll touch the most as a beginner:</p><pre>my-first-app/<br>├── public/<br>│   └── index.html     Main HTML file<br>├── src/<br>│   ├── index.js       Entry point of the app<br>│   └── App.js         Your main component</pre><h3>What these files do:</h3><ul><li><strong>index.html</strong> — The only HTML file. React injects everything here.</li><li><strong>index.js</strong> — Starts the React app and connects it to index.html</li><li><strong>App.js</strong> — Your main React component (you’ll write most code here for now)</li></ul><h3>5. A Faster, Modern Way with Vite</h3><p>Create React App is beginner-friendly, but it can be a bit slow to start.</p><p>Meet <strong>Vite</strong> a modern tool that’s super fast and better for new projects.</p><p>To use Vite:</p><pre>npm create vite@latest my-vite-app</pre><p>Then follow the prompts:</p><ul><li>Choose a framework: React</li><li>Choose a variant: JavaScript</li></ul><p>Then run:</p><pre>cd my-vite-app<br>npm install<br>npm run dev</pre><p>That’s it your Vite-powered React app is live in seconds!</p><h3>Pro Tip: Which One Should You Use?</h3><p><strong>Which tool should you use?</strong></p><ul><li><strong>Create React App (CRA):</strong> Perfect for simplicity and first-time learners. If you want a straightforward setup and don’t want to worry about extra configuration, start here.</li><li><strong>Vite:</strong> Great for a faster development experience and modern features. Once you’re comfortable with React basics, try Vite for speedier builds and a more modern workflow.</li></ul><p>If you’re just starting out, CRA is perfect. Once you’re confident, try Vite.</p><h3>Recap</h3><ul><li>Installed Node.js and npm</li><li>Created a React app using CRA</li><li>Learned what each file does</li><li>Bonus: Discovered Vite</li></ul><p>You’re now officially set up to start building with React.</p><h4>Up Next: Let’s Build Something Cool</h4><p>In the next blog, we’ll dive into:</p><p><strong>React Components: Your First LEGO Block of UI</strong></p><p>You’ll learn how to create your first custom component and make your app <em>do</em> something!</p><h4>Got Stuck?</h4><p>If something didn’t work, don’t worry it happens to all of us.<br>Leave a comment and I’ll help you out. Or Google it that’s what real devs do anyway.</p><h3>See You in the Next Lesson!</h3><p>Give yourself a pat on the back you’ve set up your first React project.<br>Ready to dive deeper? Blog 3 is coming up: <strong>“Understanding JSX &amp; Building Your First Component”</strong></p><h3>Thank you for being a part of the community</h3><p><em>Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏️<strong>️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/@InPlainEnglish"><strong>YouTube</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a> | <a href="https://twitch.tv/inplainenglish"><strong>Twitch</strong></a></li><li><a href="https://differ.blog/"><strong>Start your own free AI-powered blog on Differ</strong></a> 🚀</li><li><a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Join our content creators community on Discord</strong></a> 🧑🏻‍💻</li><li>For more content, visit <a href="https://plainenglish.io/"><strong>plainenglish.io</strong></a> + <a href="https://stackademic.com/"><strong>stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e386c2b4fb96" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/chapter-2-setting-up-react-the-easy-way-no-headaches-just-code-e386c2b4fb96">Chapter 2 : Setting Up React the Easy Way, No Headaches, Just Code</a> was originally published in <a href="https://javascript.plainenglish.io">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chapter 1 : React 101 What It Is, Why It’s Cool, and Why You Should Care]]></title>
            <link>https://javascript.plainenglish.io/chapter-1-react-101-what-it-is-why-its-cool-and-why-you-should-care-b53e62c49669?source=rss-47da65da6428------2</link>
            <guid isPermaLink="false">https://medium.com/p/b53e62c49669</guid>
            <category><![CDATA[react-course]]></category>
            <category><![CDATA[ssfu-react-course]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[frontend-development]]></category>
            <dc:creator><![CDATA[PavanBhakta]]></dc:creator>
            <pubDate>Fri, 25 Jul 2025 16:42:41 GMT</pubDate>
            <atom:updated>2025-08-03T00:28:04.094Z</atom:updated>
            <content:encoded><![CDATA[<h3>Chapter 1 : React 101 What It Is, Why It’s Cool, and Why You Should Care</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wNgIprcFF0-SiMqxR6NgQA.png" /></figure><p><em>Imagine this:</em> You’re using Instagram. You like a photo, post a comment, and scroll endlessly all without the page ever reloading. Kinda magical, right?</p><p>That’s <strong>React</strong> working behind the scenes.</p><p>In this blog, we’ll break down <strong>what React is</strong>, <strong>why it’s so popular</strong>, and how it’s different from other ways of building websites all in plain English. No fancy jargon. Just simple, beginner-friendly explanations.</p><h3>So, What is React?</h3><p>React is a tool or more technically, a <strong>JavaScript library </strong>that helps developers build the parts of a website that users interact with.</p><p>Think of things like buttons, text, images, forms basically, everything you <em>see and click</em> on a website. That’s the <strong>UI</strong>, or <strong>User Interface</strong>. React makes building these interfaces super smooth.</p><p>But here’s where it gets cooler: React is especially good for building <strong>Single Page Applications (SPAs)</strong>.</p><h3>Wait… What’s a Single Page Application?</h3><p>A SPA is a website where <strong>the page doesn’t reload every time you click something</strong>. Only the part that changed gets updated. That’s why Instagram or Gmail feel so fast — they’re using React (or something like it).</p><p>In simple terms:<br>React helps build websites that are fast, interactive, and don’t reload the whole page every time something changes.</p><h3>A Quick History Lesson</h3><p>Let’s keep it short and sweet:</p><ul><li><strong>Created By:</strong> Jordan Walke (engineer at Facebook)</li><li><strong>Released:</strong> 2013</li><li><strong>Used By:</strong> Facebook, Instagram, Netflix, WhatsApp Web — yeah, all the big names.</li></ul><p>React was created to solve a problem: building complex, dynamic websites without losing your mind.</p><h3>Why Developers Love React (And You Might Too)</h3><p>Here are the <strong>top features</strong> that make React super beginner-friendly:</p><h4>1. Component-Based</h4><p>React lets you break your UI into <strong>tiny reusable pieces</strong> — like LEGO blocks. Build once, use everywhere.</p><h4>2. Reusable</h4><p>Create a button once, use it on 10 different pages. Less code, fewer bugs.</p><h4>3. Virtual DOM</h4><p>Instead of changing the whole page every time, React uses a <strong>virtual DOM</strong> (more on this next) to update <strong>only what changed</strong>. It’s fast. Like, <em>really</em> fast.</p><h4>4. Super Efficient</h4><p>Your app stays speedy, even as it grows. That’s why big apps like Facebook use it.</p><h3>Let’s Talk About the Virtual DOM (Without Getting Bored)</h3><p>Okay, “Virtual DOM” sounds super techy, but it’s actually a genius idea and surprisingly easy to get.</p><p>Here’s an analogy:</p><p>Imagine your website is a painting.<br>If you smudge one corner, do you repaint the whole thing?<br>Of course not you fix just the smudge.</p><p>That’s exactly what React does.</p><h3>Real Explanation:</h3><ul><li>The <strong>DOM</strong> (Document Object Model) is like a tree structure of your webpage.</li><li>React creates a <strong>virtual copy</strong> of this tree in memory — the <strong>Virtual DOM</strong>.</li><li>When something changes (like a button click), React compares the new virtual DOM to the old one, sees what changed, and <strong>only updates that part</strong> of the real DOM.</li></ul><p>This is called <strong>“diffing and reconciling” </strong>and it makes React <strong>fast and efficient</strong>.</p><h3>React vs Vanilla JavaScript vs Other Frameworks</h3><p>Here’s how React stacks up against the old-school way (vanilla JS) and other frameworks like Angular:<br><strong>React</strong></p><ul><li><strong>Speed:</strong> Very fast, thanks to the virtual DOM.</li><li><strong>Structure:</strong> Component-based, making code organized and reusable.</li><li><strong>DOM Updates:</strong> Smart updates — only changes what’s needed.</li><li><strong>Reusability:</strong> High; build once, use everywhere.</li><li><strong>Learning Curve:</strong> Easy to medium for most beginners.</li></ul><p><strong>Vanilla JavaScript</strong></p><ul><li><strong>Speed:</strong> Fast, but reloads the whole page for changes.</li><li><strong>Structure:</strong> No built-in structure; code can get messy.</li><li><strong>DOM Updates:</strong> Full page reloads, less efficient.</li><li><strong>Reusability:</strong> Low; lots of repeated code.</li><li><strong>Learning Curve:</strong> Easy to start, but harder to manage big projects.</li></ul><p><strong>Angular / Other Frameworks</strong></p><ul><li><strong>Speed:</strong> Fast, with smart updates and optimizations.</li><li><strong>Structure:</strong> Very structured; lots of rules and patterns.</li><li><strong>DOM Updates:</strong> Smart or virtual DOM for efficient changes.</li><li><strong>Reusability:</strong> Medium to high, depending on the framework.</li><li><strong>Learning Curve:</strong> Medium to hard; more concepts to learn.</li></ul><p><strong>TL;DR</strong>: React is faster and more organized than vanilla JavaScript, and much easier to learn than frameworks like Angular.</p><h3>Try React Right Now (No Setup Needed)</h3><p>Here’s a quick React example you can try in <a href="https://codesandbox.io/">CodeSandbox</a> or in your local setup:</p><pre>function App() {<br>  const [count, setCount] = React.useState(0);<br><br>return (<br>    &lt;div<br>      &lt;h1You clicked {count} times&lt;/h1<br>      &lt;button onClick={() = setCount(count + 1)}<br>        Click me!<br>      &lt;/button<br>    &lt;/div<br>  );<br>}</pre><p>Every time you click the button, the number increases. But notice: <strong>the page doesn’t reload!</strong><br>Just the number changes. That’s React doing its thing.</p><h3>In a Nutshell</h3><ul><li>React is a tool for building modern, fast, user-friendly websites.</li><li>It uses <strong>components</strong> and a <strong>virtual DOM</strong> to make your life easier.</li><li>It’s used by all the cool companies.</li><li>It’s beginner-friendly and growing like crazy.</li></ul><h3>What’s Next?</h3><p>In the next post, we’ll set up your first React project (the easiest way) and write your first component together.</p><p>You’ll go from “What is React?” to “Look ma, I built a thing!” — in no time.</p><h3>Stay Tuned</h3><p>Follow me for more posts in this <strong>React for Beginners</strong> series. Next up:</p><p><strong>“Setting Up React the Easy Way: No Headaches, Just Code”</strong></p><h3>Thank you for being a part of the community</h3><p><em>Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏️<strong>️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/@InPlainEnglish"><strong>YouTube</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a> | <a href="https://twitch.tv/inplainenglish"><strong>Twitch</strong></a></li><li><a href="https://differ.blog/"><strong>Start your own free AI-powered blog on Differ</strong></a> 🚀</li><li><a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Join our content creators community on Discord</strong></a> 🧑🏻‍💻</li><li>For more content, visit <a href="https://plainenglish.io/"><strong>plainenglish.io</strong></a> + <a href="https://stackademic.com/"><strong>stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b53e62c49669" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/chapter-1-react-101-what-it-is-why-its-cool-and-why-you-should-care-b53e62c49669">Chapter 1 : React 101 What It Is, Why It’s Cool, and Why You Should Care</a> was originally published in <a href="https://javascript.plainenglish.io">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Internet’s Journey: From Your Browser to Google and Back]]></title>
            <link>https://medium.com/@bPavan16/the-internets-journey-from-your-browser-to-google-and-back-3b365e511c28?source=rss-47da65da6428------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b365e511c28</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[osi-layer]]></category>
            <category><![CDATA[computer-networking]]></category>
            <dc:creator><![CDATA[PavanBhakta]]></dc:creator>
            <pubDate>Tue, 22 Jul 2025 16:36:59 GMT</pubDate>
            <atom:updated>2025-07-22T16:36:59.869Z</atom:updated>
            <content:encoded><![CDATA[<h3>Lets Answer this Deep Dive Bit-by-Bit</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XIs7HnqbJeswOnYI5ZbLsg.png" /></figure><p>Typing www.google.com into a browser and pressing Enter kicks off a complex and coordinated series of steps involving the browser, operating system, DNS, networking stack, and remote servers.</p><p>This process can be logically broken down with the OSI model and system internals.</p><h3>🔸 Step 0: User Interaction Begins</h3><p>You open a browser (e.g., Chrome) and type www.google.com in the address bar and hit Enter.</p><h3>🔹 Layer 7: Application Layer (Browser, HTTP/HTTPS)</h3><h3>🔸 Browser Pre-checks:</h3><ul><li>Browser checks if the page is in the <strong>HTTP cache</strong> (memory/disk).</li><li>If not, it begins preparing an <strong>HTTP GET request</strong> for <a href="https://www.google.com/.">https://www.google.com/.</a></li></ul><h3>🔸 DNS Resolution:</h3><ol><li>Browser/OS first checks:</li></ol><ul><li>DNS cache in the browser</li><li>OS-level DNS cache</li><li>/etc/hosts file (Linux/macOS)</li></ul><p>2. If not found:</p><ul><li>A <strong>DNS query</strong> is sent to a <strong>recursive resolver</strong> (usually provided by the ISP or 8.8.8.8 for Google DNS).</li><li>If the resolver doesn’t have the answer:</li><li>It queries the <strong>root server</strong> → finds .com TLD server</li><li>TLD server → finds google.com nameserver</li><li>Authoritative nameserver → replies with A/AAAA record (IPv4/IPv6)</li><li>Response: www.google.com → 142.250.195.100</li></ul><h3>🔹 Layer 6: Presentation Layer (Encoding, Encryption)</h3><h3>🔸 Role:</h3><ul><li>Handles formatting and translation: e.g., converting character sets (ASCII, UTF-8), compression (gzip), and encryption.</li><li>Because HTTPS is used, data will be encrypted via <strong>TLS</strong>.</li></ul><h3>🔸 TLS Handshake:</h3><ul><li>Key Exchange:</li><li>Typically uses <strong>Elliptic Curve Diffie-Hellman (ECDHE)</strong> to securely generate a shared secret.</li><li>Both sides derive a <strong>symmetric session key</strong> to encrypt further communication.</li></ul><p>At this point, communication is secure.</p><h3>🔹 Layer 5: Session Layer (TLS Session)</h3><ul><li>The session layer maintains this <strong>secure connection</strong> (TLS session).</li><li>If you revisit Google soon, the browser may reuse the <strong>TLS session</strong> using a <strong>session ticket</strong> or <strong>session ID</strong>, skipping the full handshake.</li></ul><h3>🔹 Layer 4: Transport Layer (TCP)</h3><h3>🔸 TCP 3-Way Handshake (before TLS):</h3><ol><li><strong>SYN</strong>: Client sends a TCP segment with SYN flag to open a connection.</li><li><strong>SYN-ACK</strong>: Server replies with SYN + ACK.</li><li><strong>ACK</strong>: Client sends ACK.</li></ol><ul><li><strong>Source port</strong>: Random ephemeral port (e.g., 49500)</li><li><strong>Destination port</strong>: 443 (HTTPS)</li></ul><h3>TCP handles:</h3><ul><li><strong>Segmentation</strong>: Splitting HTTP data into <strong>segments</strong>.</li><li><strong>Reliability</strong>: Retransmission, ordering, error-checking via checksums.</li><li><strong>Flow control</strong>: via window size.</li><li><strong>Congestion control</strong>: via slow start, congestion avoidance, etc.</li></ul><h3>🔹 Layer 3: Network Layer (IP, Routing)</h3><h3>🔸 IP Packet:</h3><ul><li>Now the client builds an <strong>IP packet</strong>:</li><li><strong>Source IP</strong>: Client’s public IP (assigned by ISP/NAT)</li><li><strong>Destination IP</strong>: Google’s server IP</li><li><strong>Protocol</strong>: TCP</li><li><strong>TTL</strong>, <strong>Checksum</strong>, and <strong>Fragment Offset</strong> are set</li></ul><h3>🔹 Layer 2: Data Link Layer (Ethernet, MAC Addressing)</h3><h3>🔸 Framing:</h3><ul><li>IP packets are encapsulated into <strong>Ethernet frames</strong>.</li><li>Ethernet frame includes:</li><li><strong>Source MAC</strong>: Client NIC</li><li><strong>Destination MAC</strong>: Router’s MAC</li><li><strong>Payload</strong>: IP packet</li></ul><h3>🔸 ARP (if needed):</h3><ul><li>If the MAC of the router (default gateway) isn’t known, ARP is used:</li><li>Broadcast: “Who has IP 192.168.1.1?”</li><li>Router replies with its MAC.</li></ul><h3>🔹 Layer 1: Physical Layer (Bits, Transmission Media)</h3><h3>🔸 Signal Transmission:</h3><ul><li>Ethernet: Bits converted into <strong>electrical pulses</strong></li><li>Wi-Fi: <strong>Radio signals</strong> transmitted through antenna</li><li>Fiber optics: <strong>Light pulses</strong> for long-distance communication</li></ul><h3>🔸 Journey:</h3><ul><li>Bits → NIC → Router → Modem → ISP → Undersea cables → Backbone routers → Google Data Center</li></ul><h3>🏢 On Google’s Server</h3><ol><li>Load balancer directs traffic to a nearby server (using <strong>Anycast</strong>).</li><li>Google’s edge server terminates <strong>TLS</strong> connection.</li><li>Processes the HTTP request via <strong>HTTP server</strong> (e.g., gws).</li><li>Returns:</li></ol><ul><li>HTML page</li><li>CSS, JS, fonts, etc.</li></ul><p>All assets may come from <strong>Google’s CDN (Content Delivery Network)</strong>, such as fonts.googleapis.com.</p><h3>🔁 Reverse Path</h3><p>The response travels back to the client:</p><ul><li>Same TCP connection (persistent)</li><li>IP packet → Ethernet frame → Wi-Fi signal → Laptop</li></ul><h3>🖥️ Browser Rendering Engine</h3><ol><li><strong>HTML Parsing</strong> → DOM tree</li><li><strong>CSS Parsing</strong> → CSSOM tree</li><li>Combine → <strong>Render Tree</strong></li><li><strong>Layout</strong> → calculate positions</li><li><strong>Painting</strong> → draw pixels</li><li><strong>Compositing</strong> → display on screen</li></ol><h3>✅ TL;DR</h3><ul><li>Browser checks DNS (via system or resolver).</li><li>DNS gives IP → TCP handshake → TLS handshake.</li><li>Encrypted HTTP request sent to Google.</li><li>Google’s server responds with the homepage HTML.</li><li>Browser parses and renders the page.</li><li>All of this follows the OSI model from Application to Physical layer.</li></ul><p><strong><em>“It’s a beautiful example of how abstraction layers, distributed systems, encryption, networking, and client rendering all come together seamlessly to serve a single web page in milliseconds.”</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b365e511c28" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Power of React useContext Hook]]></title>
            <link>https://javascript.plainenglish.io/the-power-of-react-usecontext-hook-bc0479f49801?source=rss-47da65da6428------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc0479f49801</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[usecontext]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[PavanBhakta]]></dc:creator>
            <pubDate>Mon, 21 Jul 2025 10:25:13 GMT</pubDate>
            <atom:updated>2025-08-03T00:28:28.920Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Power of React’s useContext Hook</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T2axHKpieRwpMr2cV1QsiA.png" /></figure><p>You build a React app. You store a value like a username or a theme in the App component. But you need that value way down in a tiny component — maybe a button, inside a card, inside a list, inside a dashboard…</p><p>So you do the thing we all do at first:</p><pre>&lt;App username=&quot;Harry&quot;&gt;<br>  &lt;Dashboard username=&quot;Harry&quot;&gt;<br>    &lt;Sidebar username=&quot;Harry&quot;&gt;<br>      &lt;UserButton username=&quot;Harry&quot; /&gt;<br>    &lt;/Sidebar&gt;<br>  &lt;/Dashboard&gt;<br>&lt;/App&gt;</pre><p>That, my friend, is called <strong>prop drilling</strong>.</p><h3>It Works, But It Hurts</h3><p>It’s like passing a secret note in class by handing it through 4 desks. What if there was a way to <em>broadcast</em> the note so only the person who cares gets it?</p><p>That’s where useContext walks in — like a walkie-talkie in a sea of handwritten notes.</p><h3>What is useContext?</h3><p>useContext is a hook that lets your components <strong>listen in</strong> to a shared value, without it being manually passed down through props.</p><p>In other words:</p><ul><li>You <strong>create a context</strong>, a kind of shared room.</li><li>You <strong>provide a value</strong> into that room.</li><li>Any component inside that room can <strong>grab the value directly</strong>, no prop chain needed.</li></ul><h3>Let’s Build It Together</h3><h4>Step 1: Create the Context</h4><p>This is like setting up the walkie-talkie channel.</p><pre>import { createContext } from &quot;react&quot;<br><br>const UserContext = createContext();</pre><h4>Step 2: Provide the Value</h4><p>We wrap our component tree and pass the data.</p><pre>&lt;UserContext.Provider value={&quot;Harry Potter&quot;}&gt;<br>  &lt;Dashboard /&gt;<br>&lt;/UserContext.Provider&gt;</pre><p>Now anything inside &lt;Dashboard /&gt; (and its children) can access &quot;Harry Potter&quot; directly.</p><h4>Step 3: Consume the Value</h4><p>Anywhere inside that tree, we grab the value like this:</p><pre>import { useContext } from &quot;react&quot;;<br><br>const username = useContext(UserContext);<br>console.log(username); // &quot;Harry Potter&quot;</pre><p>No props. No stress. Just vibes. ✨</p><h3>A Real-World Analogy</h3><p>Imagine you’re in an office.</p><ul><li>With props: You give the message to your manager, who passes it to their manager, who passes it down to you. So many layers!</li><li>With context: There’s a bulletin board in the kitchen. You just walk in and read what you need.</li></ul><p>That’s useContext.</p><h3>Real-World Use Cases</h3><p>You’ll typically use useContext for:</p><ul><li>Authenticated user info</li><li>Theme toggles (light/dark)</li><li>Language settings (i18n)</li><li>Shopping cart items</li><li>Global app config (API base URL, feature flags)</li></ul><h3>Mini Project: A Simple “Sign In and Greet” App</h3><h3>Goal:</h3><ul><li>You’ll build a basic sign-in interface.</li><li>Once the user signs in, show a personalized greeting on any nested component.</li><li>All without prop drilling — thanks to useContext.</li></ul><h3>File Structure:</h3><pre>/src<br>  ├── App.js<br>  ├── UserContext.js<br>  ├── SignIn.js<br>  ├── Dashboard.js<br>  └── WelcomeBanner.js</pre><h3>1️. UserContext.js — Create Your Context</h3><pre>import { createContext } from &quot;react&quot;;<br><br>export const UserContext = createContext(null);</pre><h3>2️. App.js — Provide the User State</h3><pre>import React, { useState } from &quot;react&quot;;<br>import { UserContext } from &quot;./UserContext&quot;;<br>import SignIn from &quot;./SignIn&quot;;<br>import Dashboard from &quot;./Dashboard&quot;;<br><br>function App() {<br>  const [user, setUser] = useState(null);<br>  return (<br>    &lt;UserContext.Provider value={{ user, setUser }}&gt;<br>      {!user ? &lt;SignIn /&gt; : &lt;Dashboard /&gt;}<br>    &lt;/UserContext.Provider&gt;<br>  );<br>}<br>export default App;</pre><h3>3️. SignIn.js — Let User “Sign In”</h3><pre>import React, { useContext, useState } from &quot;react&quot;;<br><br>import { UserContext } from &quot;./UserContext&quot;;<br><br>function SignIn() {<br>  const { setUser } = useContext(UserContext);<br>  const [username, setUsername] = useState(&quot;&quot;);<br>  const handleSignIn = () =&gt; {<br>    if (username.trim() !== &quot;&quot;) {<br>      setUser(username);<br>    }<br>  };<br><br>  return (<br>    &lt;div style={{ textAlign: &quot;center&quot;, marginTop: &quot;50px&quot; }}&gt;<br>      &lt;h2&gt;Sign In&lt;/h2&gt;<br>      &lt;input<br>        type=&quot;text&quot;<br>        placeholder=&quot;Enter your name&quot;<br>        value={username}<br>        onChange={(e) =&gt; setUsername(e.target.value)}<br>      /&gt;<br>      &lt;button onClick={handleSignIn}&gt;Sign In&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default SignIn;</pre><h3>4️. Dashboard.js — Protected After Sign In</h3><pre>import React from &quot;react&quot;;<br>import WelcomeBanner from &quot;./WelcomeBanner&quot;;<br><br>function Dashboard() {<br>  return (<br>    &lt;div style={{ padding: &quot;20px&quot; }}&gt;<br>      &lt;h2&gt;Dashboard&lt;/h2&gt;<br>      &lt;WelcomeBanner /&gt;<br>    &lt;/div&gt;<br>  );<br>}<br>export default Dashboard;</pre><h3>5. WelcomeBanner.js — Access User Without Props</h3><pre>import React, { useContext } from &quot;react&quot;;<br><br>import { UserContext } from &quot;./UserContext&quot;;<br><br>function WelcomeBanner() {<br>  const { user } = useContext(UserContext);<br>  return &lt;h3&gt;Welcome, {user}!&lt;/h3&gt;;<br>}<br><br>export default WelcomeBanner;</pre><h3>Final Output:</h3><p>When you run this app:</p><ul><li>You’ll see a sign-in input and button.</li><li>After entering your name and clicking <strong>Sign In</strong>, it takes you to the dashboard.</li><li>Deep inside the dashboard, the WelcomeBanner shows your name — without it ever being passed down manually.</li></ul><h3>TL;DR — Summery</h3><ul><li>useContext stops the madness of prop drilling.</li><li>Think of it like a shared channel all components can tune into.</li><li>Simple to set up, even more satisfying to use.</li></ul><h3>What You Just Learned</h3><ul><li>How to <strong>store shared user data</strong> in React.</li><li>How to let <strong>any component access or update it</strong> using useContext.</li><li>How to keep things <strong>cleaner</strong> and <strong>DRY</strong> (Don’t Repeat Yourself) in your component tree.</li></ul><h3>Thank you for being a part of the community</h3><p><em>Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏️<strong>️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/@InPlainEnglish"><strong>YouTube</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a> | <a href="https://twitch.tv/inplainenglish"><strong>Twitch</strong></a></li><li><a href="https://differ.blog/"><strong>Start your own free AI-powered blog on Differ</strong></a> 🚀</li><li><a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Join our content creators community on Discord</strong></a> 🧑🏻‍💻</li><li>For more content, visit <a href="https://plainenglish.io/"><strong>plainenglish.io</strong></a> + <a href="https://stackademic.com/"><strong>stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc0479f49801" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/the-power-of-react-usecontext-hook-bc0479f49801">The Power of React useContext Hook</a> was originally published in <a href="https://javascript.plainenglish.io">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React useEffect: The Side Effect Awakens]]></title>
            <link>https://javascript.plainenglish.io/react-useeffect-the-side-effect-awakens-b5854caf48b0?source=rss-47da65da6428------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5854caf48b0</guid>
            <category><![CDATA[mern-stack]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[react-hook-useeffect]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[PavanBhakta]]></dc:creator>
            <pubDate>Sat, 19 Jul 2025 05:58:23 GMT</pubDate>
            <atom:updated>2025-08-03T00:27:57.735Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1nTjDBAC2kYVlLLmEc8BKw.png" /></figure><p>If you’ve taken your first steps into React and met useState, then you&#39;ve probably crossed paths with its more mysterious sibling: useEffect</p><p>And it looked like this:</p><pre>useEffect(() =&gt; {<br>  // something important?<br>}, []);</pre><p><strong>You paused. You stared. </strong>And then you muttered: <em>“What the heck is this thing?” </em>Don’t worry we’ve <strong>all</strong> been there.</p><p>useEffect looks cryptic at first, But I promise, it’s not as scary as it seems.</p><p>So let’s break it down not like a robot quoting documentation, but like a real human explaining it to another human… over a cup of chai or coffee.</p><h3>What is useEffect?</h3><p>Let’s imagine you built a cool component. It renders. Great. But now you want to:</p><ul><li>Fetch data from an API</li><li>Update the document title</li><li>Set a timer</li><li>Listen events</li></ul><p>Basically, you want to do <em>something</em> <strong>after</strong> React puts your UI on the screen.</p><p>That’s where useEffect comes in.</p><p><strong>useEffect lets you run code after your component renders.</strong></p><p>It’s like saying: “Hey React, once you&#39;re done showing stuff on screen , I’ve got some extra work to do.”</p><h3>Basic Syntax</h3><pre>useEffect(() =&gt; {<br>  // do something here<br>}, [dependencies]);</pre><p>Here’s how to read that:</p><ul><li>The first argument (a function) is what you want to run.</li><li>The second argument (an array) tells React <strong>when</strong> to run it.</li></ul><h3>Example 1: Hello, Console!</h3><pre>import { useEffect, useState } from &#39;react&#39;;<br><br>function App() {<br>  const [count, setCount] = useState(0);<br>  useEffect(() =&gt; {<br>    console.log(&quot;Component rendered!&quot;);<br>  });<br>  return (<br>    &lt;button onClick={() =&gt; setCount(count + 1)}&gt;<br>      Clicked {count} times<br>    &lt;/button&gt;<br>  );<br>}</pre><p>What happens here?</p><ul><li>You click the button → count changes → component re-renders</li><li>useEffect runs <strong>after every render</strong></li></ul><p>Neat. But what if we only want it to run <em>once</em>?</p><h3>Example 2: Run Only on Mount (Just Once)</h3><pre>useEffect(() =&gt; {<br>  console.log(&quot;Runs only once &quot;);<br>}, []);</pre><p>That empty array means:</p><p><em>“Only run this effect </em><strong><em>on the first render</em></strong><em>, and never again.”</em></p><p>Perfect for:</p><ul><li>Fetching API data when the page loads</li><li>Connecting to a WebSocket</li><li>Setting up a listener</li></ul><h3>Example 3: Fetching Data on Load</h3><pre>useEffect(() =&gt; {<br>  fetch(&quot;https://jsonplaceholder.typicode.com/users&quot;)<br>    .then(res =&gt; res.json())<br>    .then(data =&gt; console.log(data));<br>}, []);</pre><p>Boom. You’ve got yourself an API call that runs when the component appears.</p><h3>Example 4: Reacting to Changes</h3><pre>useEffect(() =&gt; {<br>  console.log(`Count changed to: ${count}`);<br>}, [count]);</pre><p>Now, this only runs when count changes. Not on every render. Just when <em>that specific piece of state</em> updates.</p><p>That’s what we mean when we say “dependencies.” You’re telling React: “Run this code only if these things change.”</p><h3>Example 5 : Cleanup</h3><p>Sometimes your effect creates something that needs to be cleaned up like a timer or event listener.</p><p>Use return inside your useEffect to define the <strong>cleanup function</strong></p><pre>useEffect(() =&gt; {<br>  const timer = setInterval(() =&gt; {<br>    console.log(&quot;Tick...&quot;);<br>  }, 1000);<br><br>return () =&gt; {<br>    clearInterval(timer);<br>    console.log(&quot;Cleanup done!&quot;);<br>  };<br>}, []);</pre><p>This:</p><ul><li>Starts the timer on mount</li><li>Clears it when the component unmounts</li></ul><p>This avoids memory leaks.</p><h3>TL;DR : When Does useEffect Run?</h3><ul><li><strong>No array at all?</strong><br> That means useEffect runs <strong>after every single render</strong>. Initial load, state updates, props changes — boom, it runs every time.</li><li><strong>Empty array </strong><strong>[]?</strong><br> This tells React: “Hey, just run this effect once, when the component mounts.”</li><li><strong>Array with dependencies like </strong><strong>[count]?</strong><br> Now you’re saying: “Run this effect when count changes.”<br> So it’ll run <strong>once on the first render</strong>, and again <strong>only</strong> when count changes in the future.</li></ul><h3>Final Practice</h3><p>Let’s wrap up with a fun little project</p><p>Lets build a textarea where</p><ul><li>Users can type freely.</li><li>A character count updates as they type.</li><li>The message gets “autosaved” to local storage every few seconds.</li></ul><pre>import React, { useState, useEffect } from &#39;react&#39;;<br><br>function AutoSaveNote() {<br>  const [text, setText] = useState(&#39;&#39;);<br>  const [saved, setSaved] = useState(false);<br><br>  // Load saved text from local storage on first render<br>  useEffect(() =&gt; {<br>    const savedNote = localStorage.getItem(&#39;autosave-note&#39;);<br>    if (savedNote) {<br>      setText(savedNote);<br>    }<br>  }, []);<br><br>  // Autosave effect (every 3 seconds)<br>  useEffect(() =&gt; {<br>    const interval = setInterval(() =&gt; {<br>      localStorage.setItem(&#39;autosave-note&#39;, text);<br>      setSaved(true);<br>      setTimeout(() =&gt; setSaved(false), 1000); // Show &quot;Saved!&quot; briefly<br>    }, 3000);<br><br>    return () =&gt; clearInterval(interval); // Cleanup<br>  }, [text]);<br><br>  return (<br>    &lt;div style={{ maxWidth: &#39;400px&#39;, margin: &#39;0 auto&#39;, fontFamily: &#39;sans-serif&#39; }}&gt;<br>      &lt;h2&gt;AutoSave Note&lt;/h2&gt;<br>      &lt;textarea<br>        rows=&quot;6&quot;<br>        cols=&quot;40&quot;<br>        value={text}<br>        onChange={(e) =&gt; setText(e.target.value)}<br>        placeholder=&quot;Start typing...&quot;<br>        style={{ width: &#39;100%&#39;, padding: &#39;10px&#39;, fontSize: &#39;16px&#39; }}<br>      /&gt;<br>      &lt;p&gt;Characters: {text.length}&lt;/p&gt;<br>      {saved &amp;&amp; &lt;p style={{ color: &#39;green&#39; }}&gt;Saved!&lt;/p&gt;}<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default AutoSaveNote;</pre><h3>Your Turn to Experiment!</h3><p>Try building:</p><ul><li>A live clock that updates every second</li><li>A scroll listener that hides the navbar on scroll down</li><li>A search box that fetches suggestions as you type (with debouncing!)</li></ul><h3>Final Thoughts</h3><p>The beauty of useEffect is that it brings life to your components it lets them <em>do</em> things, not just <em>look</em> a certain way.</p><p>If useState gives your component a memory</p><p>thenuseEffect gives it a <strong>brain</strong>.</p><p>Don’t be afraid to mess up. Don’t be afraid of the dependency array.<br> Try, break, fix, repeat. That’s the dev life.</p><h3>Thank you for being a part of the community</h3><p><em>Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏️<strong>️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/@InPlainEnglish"><strong>YouTube</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a> | <a href="https://twitch.tv/inplainenglish"><strong>Twitch</strong></a></li><li><a href="https://differ.blog/"><strong>Start your own free AI-powered blog on Differ</strong></a> 🚀</li><li><a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Join our content creators community on Discord</strong></a> 🧑🏻‍💻</li><li>For more content, visit <a href="https://plainenglish.io/"><strong>plainenglish.io</strong></a> + <a href="https://stackademic.com/"><strong>stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5854caf48b0" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/react-useeffect-the-side-effect-awakens-b5854caf48b0">React useEffect: The Side Effect Awakens</a> was originally published in <a href="https://javascript.plainenglish.io">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React useState() and the Art of State Maintenance]]></title>
            <link>https://javascript.plainenglish.io/react-usestate-and-the-art-of-state-maintenance-d3d3420a3400?source=rss-47da65da6428------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3d3420a3400</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[usestate-hook]]></category>
            <category><![CDATA[mergers-and-acquisitions]]></category>
            <dc:creator><![CDATA[PavanBhakta]]></dc:creator>
            <pubDate>Fri, 18 Jul 2025 03:55:47 GMT</pubDate>
            <atom:updated>2025-07-31T23:46:13.094Z</atom:updated>
            <content:encoded><![CDATA[<h3>Chapter 5: React useState() and the Art of State Maintenance</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a3GB4B6wBRB-JYUS2ftPhg.png" /></figure><p>Let’s be honest when you first start learning React and come across this magical thing called useState it feels... weird.</p><p>In the past, you had to use <strong>class components</strong> with this.state and this.setState(). But with the introduction of <strong>React Hooks</strong>, managing state in functional components became super clean and straightforward.</p><pre>const [count, setCount] = useState(0);</pre><h3>So What Even Is State?</h3><p>Imagine your app is like a whiteboard. You write some stuff on it — like a number or name — and when the user interacts, that stuff might change.</p><p><strong>That stuff = state.</strong><br> It’s just data that your component needs to keep track of.</p><p>Examples:</p><ul><li>A counter that goes up when you click a button</li><li>A form where you type your name</li><li>A theme toggle (light/dark)</li></ul><p>You need to <strong>remember</strong> those values. That’s what state does.</p><h3>Lets Meet useState hook</h3><p>In React, you use useState to create and update state in functional components. Here’s the magical line:</p><pre>const [something, setSomething] = useState(initialValue);</pre><p>Let’s break that down like friends over coffee ☕:</p><ul><li>something is the <strong>current value</strong> (like a note you’re keeping).</li><li>setSomething is a <strong>function that updates it</strong> (like a pencil to rewrite your note).</li><li>useState(initialValue) gives it a <strong>starting value</strong>.</li></ul><h3>Lets Look into a Classic UseState() Example : A Counter Component</h3><pre>import React, { useState } from &#39;react&#39;;<br>function Counter() {<br>  const [count, setCount] = useState(0); // we start at 0<br>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;Count: {count}&lt;/p&gt;<br>      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;<br>        Click Me<br>      &lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p><strong>What’s happening here?</strong></p><ul><li>We say useState(0) — which means “start at 0”</li><li>React gives us count (the value) and setCount (the changer)</li><li>Every time we click the button, setCount(count + 1) increases the number</li><li>React sees the state changed, and <strong>automatically updates the UI</strong> 💥</li></ul><h3>Simple Analogy</h3><p>Let’s pretend you’re carrying a notebook.</p><ul><li>You write down: count = 0</li><li>Every time you click a button, you erase it and write a new number.</li></ul><h3>You Can Have Multiple useState Hooks Example :</h3><pre>function Profile() {<br>  const [name, setName] = useState(&#39;&#39;);<br>  const [age, setAge] = useState(20);<br><br>return (<br>    &lt;div&gt;<br>      &lt;input<br>        placeholder=&quot;Enter your name&quot;<br>        value={name}<br>        onChange={(e) =&gt; setName(e.target.value)}<br>      /&gt;<br>      &lt;p&gt;Hello, {name || &#39;stranger&#39;}!&lt;/p&gt;<br>      &lt;button onClick={() =&gt; setAge(age + 1)}&gt;<br>        Increase Age ({age})<br>      &lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>Now your component remembers <strong>both</strong> name and age.</p><h3>Warnings — Don’t update state directly</h3><pre>count = count + 1; // ← Bad idea</pre><p>React won’t know you changed the value. Always use the setCount() function.</p><h3>State Updates Can Be Delayed</h3><p>If you’re doing multiple updates back-to-back, React might batch them.</p><p>So instead of:</p><pre>setCount(count + 1);<br>setCount(count + 1);</pre><p>Do this instead:</p><pre>setCount(prev =&gt; prev + 1);<br>setCount(prev =&gt; prev + 1); // This will actually add 2!</pre><h3>Using useState( ) with Arrays and Objects</h3><pre>const [todos, setTodos] = useState([]);<br>setTodos(prev =&gt; [...prev, { text: &#39;Learn useState&#39;, done: false }]);</pre><p>You can store anything — just remember to <strong>copy the old state first</strong> before updating it (React doesn’t like it when you mutate things directly).</p><h3>Example Project : Light/Dark Mode Toggle</h3><pre>function ThemeToggle() {<br>  const [dark, setDark] = useState(false);<br><br>  return (<br>    &lt;div style={{<br>      background: dark ? &#39;#222&#39; : &#39;#fff&#39;,<br>      color: dark ? &#39;#fff&#39; : &#39;#000&#39;,<br>      padding: &#39;2rem&#39;<br>    }}&gt;<br>      &lt;p&gt;{dark ? &#39;🌙 Dark&#39; : &#39;☀️ Light&#39;} Mode&lt;/p&gt;<br>      &lt;button onClick={() =&gt; setDark(prev =&gt; !prev)}&gt;<br>        Toggle Theme<br>      &lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><h3>What’s Next?</h3><p>After useState, the next most important Hook is useEffect. That’s what lets you run code when your component loads, updates, or disappears.</p><h3>Let’s Wrap It Up</h3><p>So here’s what we’ve learned:</p><ul><li>useState lets you <strong>remember stuff</strong> in your component.</li><li>It returns a value + a function to change it.</li><li>You can use it as many times as you want.</li><li>It works with numbers, strings, objects, arrays — anything.</li><li>Always use the setter function (setSomething) to update.</li></ul><h3>Remember This:</h3><p>State = memory<br> useState() = a way to make React remember things<br> Updating state = React redraws the screen with new info</p><p>If this helped make things click, share it with someone who’s just starting out — and if you want me to break down useEffect next, drop a comment. 💬</p><blockquote>Until then:<br> <strong>Keep coding. Keep learning. React on.</strong></blockquote><h3>Thank you for being a part of the community</h3><p><em>Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏️<strong>️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/@InPlainEnglish"><strong>YouTube</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a> | <a href="https://twitch.tv/inplainenglish"><strong>Twitch</strong></a></li><li><a href="https://differ.blog/"><strong>Start your own free AI-powered blog on Differ</strong></a> 🚀</li><li><a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Join our content creators community on Discord</strong></a> 🧑🏻‍💻</li><li>For more content, visit <a href="https://plainenglish.io/"><strong>plainenglish.io</strong></a> + <a href="https://stackademic.com/"><strong>stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3d3420a3400" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/react-usestate-and-the-art-of-state-maintenance-d3d3420a3400">React useState() and the Art of State Maintenance</a> was originally published in <a href="https://javascript.plainenglish.io">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>