<?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 Harrshaa  on Medium]]></title>
        <description><![CDATA[Stories by Harrshaa  on Medium]]></description>
        <link>https://medium.com/@mutakodoor.sriharsha?source=rss-4e5b5c3bfaa7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qscUNS6jTcphWov1IOCEnA.jpeg</url>
            <title>Stories by Harrshaa  on Medium</title>
            <link>https://medium.com/@mutakodoor.sriharsha?source=rss-4e5b5c3bfaa7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 08:05:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mutakodoor.sriharsha/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[React Hooks]]></title>
            <link>https://medium.com/@mutakodoor.sriharsha/react-hooks-5a9f45e1f6e1?source=rss-4e5b5c3bfaa7------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a9f45e1f6e1</guid>
            <category><![CDATA[react-hooks-for-beginners]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Harrshaa ]]></dc:creator>
            <pubDate>Sun, 27 Jul 2025 12:35:02 GMT</pubDate>
            <atom:updated>2025-07-27T12:35:02.573Z</atom:updated>
            <content:encoded><![CDATA[<p>Understanding useState and useEffect in React — With a Real Example</p><p>React Hooks are powerful tools that let us add state and side effects to functional components. In this article, we’ll explore how useState and useEffect work using a practical project: fetching and displaying restaurant data from Swiggy’s API.</p><pre>import React, { useEffect, useState } from &quot;react&quot;;<br><br>const Body = () =&gt; {<br>  const [restaurantList, setRestaurantList] = useState([]);<br><br>  useEffect(() =&gt; {<br>    const fetchData = async () =&gt; {<br>      const data = await fetch(<br>        &quot;https://www.swiggy.com/dapi/restaurants/list/v5?lat=17.5366218&amp;lng=78.4844811&amp;is-seo-homepage-enabled=true&amp;page_type=DESKTOP_WEB_LISTING&quot;<br>      );<br>      const json = await data.json();<br>      const restaurants =<br>        json.data?.cards?.[4]?.card?.card?.gridElements?.infoWithStyle?.restaurants || [];<br>      setRestaurantList(restaurants);<br>    };<br><br>    fetchData();<br>  }, []);<br><br>  return (<br>    &lt;div className=&quot;body&quot;&gt;<br>      &lt;div className=&quot;search&quot;&gt;Search&lt;/div&gt;<br>      &lt;div className=&quot;res-container&quot;&gt;<br>        {restaurantList.map((item, index) =&gt; {<br>          if (!item.info?.cloudinaryImageId) return null;<br>          return &lt;RestaurantCard key={index} resData={item.info} /&gt;;<br>        })}<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br></pre><p>What useState Does ?</p><pre>const [restaurantList, setRestaurantList] = useState([])</pre><ul><li>restaurantList is a state variable that holds the current list of restaurants.</li><li>setRestaurantList is a function that lets us <strong>update</strong> this state.</li><li>Initially, it’s an empty array ([]), so nothing renders.</li></ul><p>What useEffect Does ?</p><pre>useEffect(() =&gt; {<br>  // Runs AFTER the component is first rendered<br>}, []);</pre><ul><li>The useEffect runs <strong>after</strong> the first render.</li><li>It fetches data from the API.</li><li>Once the data arrives, it <strong>updates the state</strong> via setRestaurantList.</li></ul><p>This triggers a <strong>re-render</strong>, and now the restaurant cards will be displayed.</p><h3>The Render Cycle Explained</h3><ol><li>Initial renderrestaurantList = [], nothing is shown</li><li>useEffect runsFetches data from API</li><li>State updatedrestaurantList gets real data</li><li>Re-render , Now restaurants are displayed using .map()</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a9f45e1f6e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Map Leetcode TwoSum]]></title>
            <link>https://medium.com/@mutakodoor.sriharsha/javascript-map-leetcode-twosum-52c7aa350917?source=rss-4e5b5c3bfaa7------2</link>
            <guid isPermaLink="false">https://medium.com/p/52c7aa350917</guid>
            <dc:creator><![CDATA[Harrshaa ]]></dc:creator>
            <pubDate>Sun, 02 Jul 2023 19:10:02 GMT</pubDate>
            <atom:updated>2023-07-02T19:10:02.604Z</atom:updated>
            <content:encoded><![CDATA[<p>Underrated Data Structure</p><p>Maps are similar to objects. they have keys and values.there are many advantages of maps over objects.</p><p>object keys are not ordered, whereas map keys are ordered based on insertion. Objects lack a built-in method to determine their length or size, whereas maps provide a built-in method called “size” for this purpose. Objects cannot be directly iterated, but maps can be iterated directly. Object keys are restricted to strings or symbols, whereas map keys can encompass a wide range of possibilities, including functions or objects.</p><p>useful methods of map are :-</p><ol><li>has: returns boolean signifying whether or not the map contains a key</li><li>set: sets a key in the map to a specific value</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*GZ8dytV4dmm1nLAq-b2CjA.png" /><figcaption>Solving Leetcode Two-Sum using Map</figcaption></figure><pre>var twoSum=function(nums,target){<br>let map=new Map(); //Declare map//<br>for (let i=0;i&lt;nums.length;i++){<br>if(map.has(target-nums[i])){<br>return [map.get(target-nums[i),i];<br>}<br>else<br>map.set(nums[i],i);</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52c7aa350917" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>