<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>React web app &gt; Metasys Software Pvt Ltd.</title>
	<atom:link href="https://www.metasyssoftware.com/tag/react-web-app/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.metasyssoftware.com</link>
	<description>Unique People, Unique Solutions</description>
	<lastBuildDate>Tue, 28 May 2024 11:21:51 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.metasyssoftware.com/wp-content/uploads/2023/10/metasys-svg-.png</url>
	<title>React web app &gt; Metasys Software Pvt Ltd.</title>
	<link>https://www.metasyssoftware.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>React Redux &#8211; The art of state management</title>
		<link>https://www.metasyssoftware.com/react/react-redux-the-art-of-state-management/</link>
					<comments>https://www.metasyssoftware.com/react/react-redux-the-art-of-state-management/#respond</comments>
		
		<dc:creator><![CDATA[meta_prasad]]></dc:creator>
		<pubDate>Thu, 27 Aug 2020 13:42:18 +0000</pubDate>
				<category><![CDATA[React]]></category>
		<category><![CDATA[Outsourcing React services]]></category>
		<category><![CDATA[Outsourcing React development]]></category>
		<category><![CDATA[React JS]]></category>
		<category><![CDATA[Offshore React services]]></category>
		<category><![CDATA[React Redux]]></category>
		<category><![CDATA[Outsourcing React development company]]></category>
		<category><![CDATA[React Native]]></category>
		<category><![CDATA[React developer]]></category>
		<category><![CDATA[React JS development company]]></category>
		<category><![CDATA[React Native app development]]></category>
		<category><![CDATA[React native developer]]></category>
		<category><![CDATA[React web app]]></category>
		<category><![CDATA[React mobile development company]]></category>
		<guid isPermaLink="false">https://www.metasyssoftware.com/?p=3182</guid>

					<description><![CDATA[<p>React is one of the most popular technologies for front-end development, which uses a component based approach to enable fast [&#8230;]</p>
The post <a href="https://www.metasyssoftware.com/react/react-redux-the-art-of-state-management/">React Redux – The art of state management</a> appeared first on <a href="https://www.metasyssoftware.com">Metasys Software Pvt Ltd.</a>.]]></description>
										<content:encoded><![CDATA[<p><strong>React</strong> is one of the most popular technologies for front-end development, which uses a component based approach to enable fast app development. <strong>Redux</strong> is a predictable state container for JS apps, and works particularly well with React.  In this article, I will be covering some basics on how to set up React-Redux for state management of a UI.</p>
<p>To illustrate the advantages of this approach, have a look at the UI structure shown below.</p>
<p><img fetchpriority="high" decoding="async" class="aligncenter wp-image-3183 size-full" title="UI structure image 1" src="https://www.metasyssoftware.com/wp-content/uploads/2022/07/RRAM_1.png" alt="UI structure image 1" width="643" height="361" /></p>
<p>Let’s say the functionality required is that when a user interacts with the big component, the application has to update the small component and the header. In other words, we need to sync the header and small component as well as manage the states of all the other components. Without a state management library such as the one provided by Redux, coding this implementation can easily become very complicated.</p>
<p>Using the state functionality in React allows only the use of local, component level states.</p>
<p><img decoding="async" class="size-full wp-image-3184 aligncenter" src="https://www.metasyssoftware.com/wp-content/uploads/2022/07/RRAM_2.png" alt="Image 2" width="252" height="52" /></p>
<p>You can store the states using setState method, and fetch the stored state using state.[STATE_NAME]. However, these states are local, and only available within the class component in which it is declared.</p>
<p><img decoding="async" class="aligncenter wp-image-3185 size-full" title="Setstate image3" src="https://www.metasyssoftware.com/wp-content/uploads/2022/07/RRAM_3.png" alt="Setstate image3" width="575" height="133" /></p>
<p>To store the states at the application level, i.e. the global level, in order to access them from different components, we can use React-Redux.</p>
<p><strong><u>Let’s see how React-Redux works</u></strong></p>
<p>You will see three main elements in the Redux architecture – Store, Dispatch Actions and Reducers.</p>
<p><img loading="lazy" decoding="async" class="size-full wp-image-3186 aligncenter" src="https://www.metasyssoftware.com/wp-content/uploads/2022/07/RRAM_4.png" alt="Redux architecture 4" width="642" height="319" /></p>
<p><strong>Store</strong>: holds the states at the application level, and allows any component to get data from the store in the form of Redux States.</p>
<p><strong>Dispatch Action:</strong> a function of the Redux Store to trigger a state change.</p>
<p><strong>Reducers</strong>: It handles the value change in Redux State.</p>
<p><strong><u>How to configure React Redux in a React JS project –</u></strong></p>
<p>The following packages are needed to be installed to configure  Redux in the project &#8211;</p>
<ol>
<li><strong>Redux</strong>: the core package of React Redux.</li>
<li><strong>React-redux:</strong> needed for React bindings.</li>
<li><strong>Redux-thunk: </strong>a middleware which allows you to call action creators, and which returns a function instead of the action object.</li>
</ol>
<p>These dependencies can be installed by using the following NPM command &#8211;<br />
“<strong>npm install redux react-redux redux-thunk &#8211;save</strong>”</p>
<p>After these dependencies are installed, a store can be created and initialized with data/null values as per the requirements. This can be done by creating the file store.js in the project.</p>
<p>First however, you need to create reducer.js to handle the next states. Below is the example of reducer.js to initialize the state. Here, it is just returning the initial value from the reducer.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-3187 size-full" title="reducer.js 5" src="https://www.metasyssoftware.com/wp-content/uploads/2022/07/RRAM_5.png" alt="reducer.js 5" width="447" height="150" /></p>
<p>Below is a slightly more complex example of the code in reducer.js to update the states based on the action executed from the component.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-3188 size-full" title="coding 6" src="https://www.metasyssoftware.com/wp-content/uploads/2022/07/RRAM_6.png" alt="coding 6" width="425" height="261" /></p>
<p>In the above example, it adds the data to the state upon the dispatch action (ADD_DATA). Now let’s create the action to dispatch. You can create a file with the name action.js, that contains the code shown below.</p>
<p><img loading="lazy" decoding="async" class="size-full wp-image-3189 aligncenter" src="https://www.metasyssoftware.com/wp-content/uploads/2022/07/RRAM_7.png" alt="action.js 7" width="379" height="113" /></p>
<p>Once the action is created, now you can create a store and then connect the store to the application. You can create a file with the name store.js, that contains the code shown below.</p>
<p><img loading="lazy" decoding="async" class="wp-image-3190 size-full aligncenter" title="store.js 8" src="https://www.metasyssoftware.com/wp-content/uploads/2022/07/RRAM_8.png" alt="store.js 8" width="478" height="251" /></p>
<p>To connect the store to the application, you will have to use the entry point. In the index.js (i.e. entry point of the app), import the store as shown below &#8211;</p>
<p><img loading="lazy" decoding="async" class="size-full wp-image-3191 aligncenter" src="https://www.metasyssoftware.com/wp-content/uploads/2022/07/RRAM_9.png" alt="coding 9" width="367" height="249" /></p>
<p>These are all the Redux configurations for an application. Refer the the image below to use it in your component –</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-3192 size-full" title="React component 10" src="https://www.metasyssoftware.com/wp-content/uploads/2022/07/RRAM_10.png" alt="React component 10" width="642" height="671" /></p>
<p><a href="https://www.metasyssoftware.com/react">React Redux</a> can handle large amounts of data at the application level with cleaner components and is particularly useful for big applications.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-3193 size-full" title="Without Redux 11" src="https://www.metasyssoftware.com/wp-content/uploads/2022/07/RRAM_11.png" alt="Without Redux 11" width="336" height="317" /></p>
<p><img loading="lazy" decoding="async" class="wp-image-3194 size-full aligncenter" title="With Redux 12" src="https://www.metasyssoftware.com/wp-content/uploads/2022/07/RRAM_12.png" alt="With Redux 12" width="336" height="288" /></p>
<p>Without redux, to transfer data from component 1 to component 5, you need to pass it through middle components. This increases the props for components and creates more complexity and the components are less clean.</p>
<p>Using React-Redux, you can get or set the data to the store from any of the components directly by mapping the redux states to component props. In this case, you do not need to pass props to the middle components. This allows for much cleaner components and increased clarity in the code.</p>
<p>If you are looking to build a mobile or web application using React technology, then please feel free to contact us.</p>The post <a href="https://www.metasyssoftware.com/react/react-redux-the-art-of-state-management/">React Redux – The art of state management</a> appeared first on <a href="https://www.metasyssoftware.com">Metasys Software Pvt Ltd.</a>.]]></content:encoded>
					
					<wfw:commentRss>https://www.metasyssoftware.com/react/react-redux-the-art-of-state-management/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
