<?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>changes are initiated through actions in redux - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/changes-are-initiated-through-actions-in-redux/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/changes-are-initiated-through-actions-in-redux/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Wed, 04 May 2022 05:31:14 +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.wikitechy.com/interview-questions/wp-content/uploads/2025/10/cropped-wikitechy-icon-32x32.png</url>
	<title>changes are initiated through actions in redux - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/changes-are-initiated-through-actions-in-redux/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>What are the three principles that Redux follows ?</title>
		<link>https://www.wikitechy.com/interview-questions/reactjs/what-are-the-three-principles-that-redux-follows/</link>
					<comments>https://www.wikitechy.com/interview-questions/reactjs/what-are-the-three-principles-that-redux-follows/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Mon, 28 Mar 2022 06:53:26 +0000</pubDate>
				<category><![CDATA[ReactJS]]></category>
		<category><![CDATA[a store is an object tree in redux]]></category>
		<category><![CDATA[changes are initiated through actions in redux]]></category>
		<category><![CDATA[Fundamental Principles of Redux]]></category>
		<category><![CDATA[list down the components of redux]]></category>
		<category><![CDATA[reducer in redux]]></category>
		<category><![CDATA[reducers are a pure function in redux]]></category>
		<category><![CDATA[redux concept]]></category>
		<category><![CDATA[Redux Core Principles Explained]]></category>
		<category><![CDATA[the following statements are true about redux except]]></category>
		<category><![CDATA[what are the key principles of redux]]></category>
		<category><![CDATA[What are the three principles that Redux follows]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4017</guid>

					<description><![CDATA[Redux is one of the most trending libraries for front-end development in today’s marketplace. There are three principles in redux: Single source of truth State is read-only Changes are made with pure functions Single source of truth: The entire application is stored in an object/ state tree within a single store. It debugs or inspects the application [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-4263 aligncenter" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/03/react-redux.png" alt="" width="859" height="528" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/03/react-redux.png 859w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/03/react-redux-300x184.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/03/react-redux-768x472.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/03/react-redux-390x240.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/03/react-redux-820x504.png 820w" sizes="(max-width: 859px) 100vw, 859px" /></p>
<ul>
<li>Redux is one of the most trending libraries for front-end development in today’s marketplace.</li>
<li>There are three principles in redux:
<ul>
<li><strong>Single source of truth</strong></li>
<li><strong><em>State is read-only</em></strong></li>
<li><strong>Changes are made with pure functions</strong></li>
</ul>
</li>
</ul>
<p><img decoding="async" class="alignnone size-full wp-image-4057" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/03/redux-core-principle.png" alt="" width="919" height="492" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/03/redux-core-principle.png 919w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/03/redux-core-principle-300x161.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/03/redux-core-principle-768x411.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/03/redux-core-principle-390x209.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/03/redux-core-principle-820x439.png 820w" sizes="(max-width: 919px) 100vw, 919px" /></p>
<p><strong>Single source of truth:</strong></p>
<ul>
<li>The entire application is stored in an object/ state tree within a single store.</li>
<li>It debugs or inspects the application and easier to keep track of changes over time.</li>
<li>It has been traditionally difficult to implement &#8211; Undo/Redo.</li>
<li>If all of your states is stored in a single tree, it can be suddenly trivial to implement.</li>
</ul>
<p><em><strong>For</strong></em><em> <strong>example,</strong></em></p>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markup code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markup code-embed-code">console.log(store.getState())<br/><br/>/* Prints<br/>{<br/>  visibilityFilter: &#039;SHOW_ALL&#039;,<br/>  todos: [<br/>    {<br/>      text: &#039;Consider using Redux&#039;,<br/>      completed: true,<br/>    },<br/>    {<br/>      text: &#039;Keep all state in a single tree&#039;,<br/>      completed: false<br/>    }<br/>  ]<br/>}<br/>*/</code></pre> </div>
<p><img decoding="async" class="alignnone size-full wp-image-4265 aligncenter" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/03/redux-data-flow.jpg" alt="" width="642" height="472" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/03/redux-data-flow.jpg 642w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/03/redux-data-flow-300x221.jpg 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/03/redux-data-flow-390x287.jpg 390w" sizes="(max-width: 642px) 100vw, 642px" /></p>
<p><strong>State is read-only:</strong></p>
<ul>
<li style="text-align: justify;">The only way to change the state is to emit an action, an object describing what happened.</li>
<li style="text-align: justify;">It ensures that neither the views nor the network callbacks will ever write directly to the state.</li>
<li style="text-align: justify;">All changes are centralized and happen one by one in a strict order, there are no subtle race conditions to watch out for.</li>
<li style="text-align: justify;">The minimal representation of data is just like state, the action is the minimal representation of the change to that data.</li>
</ul>
<p><strong>For</strong> <strong>example,</strong></p>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markup code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markup code-embed-code">store.dispatch({<br/>  type: &#039;COMPLETE_TODO&#039;,<br/>  index: 1<br/>})<br/><br/>store.dispatch({<br/>  type: &#039;SET_VISIBILITY_FILTER&#039;,<br/>  filter: &#039;SHOW_COMPLETED&#039;<br/>})</code></pre> </div>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4266" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/03/redux-data-flow-diagram.gif" alt="" width="800" height="700" /></p>
<p><strong>Changes are made with pure functions:</strong></p>
<ul>
<li>To specify how the state tree is transformed by actions, you write pure reducers<strong>.</strong></li>
<li>Pure functions are those whose return value depends solely on the values of their arguments.</li>
<li>Reducers are just functions, you can control the order in which they are called, pass additional data, or even make reusable reducers for common tasks such as pagination.</li>
</ul>
<p><strong>For</strong> <strong>example,</strong></p>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markup code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markup code-embed-code">function visibilityFilter(state = &#039;SHOW_ALL&#039;, action) {<br/>  switch (action.type) {<br/>    case &#039;SET_VISIBILITY_FILTER&#039;:<br/>      return action.filter<br/>    default:<br/>      return state<br/>  }<br/>}<br/><br/>function todos(state = [], action) {<br/>  switch (action.type) {<br/>    case &#039;ADD_TODO&#039;:<br/>      return [<br/>        ...state,<br/>        {<br/>          text: action.text,<br/>          completed: false<br/>        }<br/>      ]<br/>    case &#039;COMPLETE_TODO&#039;:<br/>      return state.map((todo, index) =&gt; {<br/>        if (index === action.index) {<br/>          return Object.assign({}, todo, {<br/>            completed: true<br/>          })<br/>        }<br/>        return todo<br/>      })<br/>    default:<br/>      return state<br/>  }<br/>}<br/><br/>import { combineReducers, createStore } from &#039;redux&#039;<br/>const reducer = combineReducers({ visibilityFilter, todos })<br/>const store = createStore(reducer)</code></pre> </div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/reactjs/what-are-the-three-principles-that-redux-follows/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
