<?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 Haritha Parthasarathi on Medium]]></title>
        <description><![CDATA[Stories by Haritha Parthasarathi on Medium]]></description>
        <link>https://medium.com/@haritha_40588?source=rss-a563116dac61------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*eDRcbQM_FD5uoO5-.jpg</url>
            <title>Stories by Haritha Parthasarathi on Medium</title>
            <link>https://medium.com/@haritha_40588?source=rss-a563116dac61------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 22:55:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@haritha_40588/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[What is Redux?]]></title>
            <link>https://medium.com/@haritha_40588/what-is-redux-143de3703ba3?source=rss-a563116dac61------2</link>
            <guid isPermaLink="false">https://medium.com/p/143de3703ba3</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[redux]]></category>
            <dc:creator><![CDATA[Haritha Parthasarathi]]></dc:creator>
            <pubDate>Thu, 17 Sep 2020 04:57:43 GMT</pubDate>
            <atom:updated>2020-09-17T04:57:43.390Z</atom:updated>
            <content:encoded><![CDATA[<p>Before Redux, we need to know about state management. State management is a technique or a way to store/maintain the state of the React application.</p><p>Redux is a state management tool that manages the entire state of the application in a single immutable object tree. It cannot be directly edited. If we would want to edit, we need to create a new object.Here the new object contains the new state or updated state of the application.</p><p><strong>Why Redux?</strong></p><p>React has it’s own state components, so why we need Redux to manage state?</p><p>We shall look into an example to understand these aspects</p><p>The figure below shows a hierarchical structure of the flow of the state (which in this case is ‘<strong>name</strong>’), which is initiated at the App level and flows through various components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lgRLyrLWEvDul3D-bKnu_Q.png" /><figcaption>Figure 1 : Demonstrating the State flow over various Components</figcaption></figure><p>If the ‘<strong>name</strong>’ is a state and component is ‘<strong>G</strong>’ , in the event <strong>‘G’</strong> wants to access the ‘<strong>name</strong>’, it would need to traverse from the component ‘<strong>App</strong>’, all the way to the component ‘<strong>G</strong>’. Think about this same flow for large applications, it would have <strong>‘n</strong>’ number of states. If for all the states, we would need to traverse the whole application, it would mean that we need to put more effort into states and therefore the efficiency would suffer, effecting the application usage.</p><p>The following Figure 2, showcases how using Redux, we can alleviate this problem,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LwgkpzfL-j5vduJbw38Bmw.png" /><figcaption>Figure 2 : Redux in action for the same environment as Fig 1</figcaption></figure><p>As you see in the diagram above, Redux maintains all the states into a single object tree. We see the state ‘<strong>name</strong>’ can be accessible with ease by each of the components, without having to wait for the hierarchical flow of the state. Directly the state ‘<strong>name</strong>’ can be accessed by any of the components , directly from the Redux state container and does not have to traverse the whole application.</p><h3>Concepts of Redux</h3><p>The core concepts of redux are,</p><ol><li>Store</li><li>Action</li><li>Reducer</li><li><strong>Store</strong>: holds the overall state of the application.</li></ol><p>Let us consider an example :</p><p>You are going to buy a flower or bouquet at a florist’s store.</p><p>Here the <strong>flower shop</strong> is the <strong>store</strong> which contains all type of flowers.</p><pre>{<br>  no_of_flowers : 10<br>}</pre><p>2<strong>. Action </strong>describes what happens.</p><p>If we need to update the state, we need to let Redux know about that using actions.</p><pre>{<br>  type : Buy_Flower<br>}</pre><p>Here, the type is an argument and <strong>Buy_flower</strong> is a constant. As we intend to buy a flower, Hence the action is <strong>Buy_flower .</strong></p><p>3.<strong> Reducer </strong>specify how the app’s state changes in response to actions</p><p>Here reducer acts like a shopkeeper. The shopkeeper asks us what we want and then fulfill our requirements.</p><p>The Reducer will basically require two arguments, one is the current state of the application and the other one is the action to be performed. On success, the state of the application is updated.</p><pre>flowerReducer(state=prevState,action)<br>{<br> switch(type)<br> {<br> case Buy_flower:<br> return {<br> no_of_flowers : state.no_of_flowers-1<br> }<br> }<br>}</pre><h3>Summary</h3><p>A React app dispatches the <strong><em>action</em></strong> to the reducer with the <strong><em>previous state</em></strong> and <strong><em>action type</em></strong>. The reducer then creates a <strong><em>new state</em></strong> in the store, which has been subscribed to by the respective application and then gives the <strong><em>updated state</em></strong> to that React application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=143de3703ba3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>