<br />
<b>Warning</b>:  Undefined array key "global_protection_id" in <b>/home/wikitechy/public_html/interview-questions/wp-content/plugins/content-protector/inc/class-ps-rest-handler.php</b> on line <b>51</b><br />
{"id":4017,"date":"2022-03-28T06:53:26","date_gmt":"2022-03-28T06:53:26","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=4017"},"modified":"2022-05-04T05:31:14","modified_gmt":"2022-05-04T05:31:14","slug":"what-are-the-three-principles-that-redux-follows","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-three-principles-that-redux-follows\/","title":{"rendered":"What are the three principles that Redux follows ?"},"content":{"rendered":"<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>\n<ul>\n<li>Redux is one of the most trending libraries for front-end development in today\u2019s marketplace.<\/li>\n<li>There are three principles in redux:\n<ul>\n<li><strong>Single source of truth<\/strong><\/li>\n<li><strong><em>State\u00a0is read-only<\/em><\/strong><\/li>\n<li><strong>Changes are made with pure functions<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<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>\n<p><strong>Single source of truth:<\/strong><\/p>\n<ul>\n<li>The entire application is stored in an object\/ state tree within a single\u00a0store.<\/li>\n<li>It debugs or inspects the application and easier to keep track of changes over time.<\/li>\n<li>It has been traditionally difficult to implement &#8211; Undo\/Redo.<\/li>\n<li>If all of your states is stored in a single tree, it can be suddenly trivial to implement.<\/li>\n<\/ul>\n<p><em><strong>For<\/strong><\/em><em> <strong>example,<\/strong><\/em><\/p>\n<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\/>\u00a0 visibilityFilter: &#039;SHOW_ALL&#039;,<br\/>\u00a0 todos: [<br\/>\u00a0\u00a0\u00a0 {<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0 text: &#039;Consider using Redux&#039;,<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0 completed: true,<br\/>\u00a0\u00a0\u00a0 },<br\/>\u00a0\u00a0\u00a0 {<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0 text: &#039;Keep all state in a single tree&#039;,<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0 completed: false<br\/>\u00a0\u00a0\u00a0 }<br\/>\u00a0 ]<br\/>}<br\/>*\/<\/code><\/pre> <\/div>\n<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>\n<p><strong>State\u00a0is read-only:<\/strong><\/p>\n<ul>\n<li style=\"text-align: justify;\">The only way to change the state is to emit an\u00a0action, an object describing what happened.<\/li>\n<li style=\"text-align: justify;\">It ensures that neither the views nor the network callbacks will ever write directly to the state.<\/li>\n<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>\n<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>\n<\/ul>\n<p><strong>For<\/strong> <strong>example,<\/strong><\/p>\n<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>\n<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>\n<p><strong>Changes are made with pure functions:<\/strong><\/p>\n<ul>\n<li>To specify how the state tree is transformed by actions, you write pure\u00a0reducers<strong>.<\/strong><\/li>\n<li>Pure functions are\u00a0those whose return value depends solely on the values of their arguments.<\/li>\n<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>\n<\/ul>\n<p><strong>For<\/strong> <strong>example,<\/strong><\/p>\n<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>\n","protected":false},"excerpt":{"rendered":"<p>Redux is one of the most trending libraries for front-end development in today\u2019s marketplace. There are three principles in redux: Single source of truth State\u00a0is 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\u00a0store. It debugs or inspects the application [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"passster_activate_protection":false,"passster_protect_child_pages":"","passster_protection_type":"password","passster_password":"","passster_activate_overwrite_defaults":"","passster_headline":"","passster_instruction":"","passster_placeholder":"","passster_button":"","passster_id":"","passster_activate_misc_settings":"","passster_redirect_url":"","passster_hide":"no","passster_area_shortcode":"","gtb_hide_title":false,"gtb_wrap_title":false,"gtb_class_title":"","gtb_remove_headerfooter":false,"footnotes":""},"categories":[16542],"tags":[16826,16830,16821,16828,16827,16825,16824,16822,16829,16823,16820],"class_list":["post-4017","post","type-post","status-publish","format-standard","hentry","category-reactjs","tag-a-store-is-an-object-tree-in-redux","tag-changes-are-initiated-through-actions-in-redux","tag-fundamental-principles-of-redux","tag-list-down-the-components-of-redux","tag-reducer-in-redux","tag-reducers-are-a-pure-function-in-redux","tag-redux-concept","tag-redux-core-principles-explained","tag-the-following-statements-are-true-about-redux-except","tag-what-are-the-key-principles-of-redux","tag-what-are-the-three-principles-that-redux-follows"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What are the three principles that Redux follows ? - ReactJS - Wikitechy<\/title>\n<meta name=\"description\" content=\"What are the three principles that Redux follows ? - Redux is one of the most trending libraries for front-end development in today\u2019s marketplace.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-three-principles-that-redux-follows\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What are the three principles that Redux follows ? - ReactJS - Wikitechy\" \/>\n<meta property=\"og:description\" content=\"What are the three principles that Redux follows ? - Redux is one of the most trending libraries for front-end development in today\u2019s marketplace.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-three-principles-that-redux-follows\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-28T06:53:26+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-05-04T05:31:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/react-redux.png\" \/>\n<meta name=\"author\" content=\"webmaster\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webmaster\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-three-principles-that-redux-follows\/\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-three-principles-that-redux-follows\/\",\"name\":\"What are the three principles that Redux follows ? - ReactJS - Wikitechy\",\"isPartOf\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-three-principles-that-redux-follows\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-three-principles-that-redux-follows\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/react-redux.png\",\"datePublished\":\"2022-03-28T06:53:26+00:00\",\"dateModified\":\"2022-05-04T05:31:14+00:00\",\"author\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\"},\"description\":\"What are the three principles that Redux follows ? - Redux is one of the most trending libraries for front-end development in today\u2019s marketplace.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-three-principles-that-redux-follows\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-three-principles-that-redux-follows\/#primaryimage\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/react-redux.png\",\"contentUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/react-redux.png\",\"width\":859,\"height\":528},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\",\"name\":\"webmaster\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"caption\":\"webmaster\"},\"sameAs\":[\"https:\/\/www.wikitechy.com\/interview-questions\"],\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What are the three principles that Redux follows ? - ReactJS - Wikitechy","description":"What are the three principles that Redux follows ? - Redux is one of the most trending libraries for front-end development in today\u2019s marketplace.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-three-principles-that-redux-follows\/","og_locale":"en_US","og_type":"article","og_title":"What are the three principles that Redux follows ? - ReactJS - Wikitechy","og_description":"What are the three principles that Redux follows ? - Redux is one of the most trending libraries for front-end development in today\u2019s marketplace.","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-three-principles-that-redux-follows\/","og_site_name":"Wikitechy","article_published_time":"2022-03-28T06:53:26+00:00","article_modified_time":"2022-05-04T05:31:14+00:00","og_image":[{"url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/react-redux.png"}],"author":"webmaster","twitter_card":"summary_large_image","twitter_misc":{"Written by":"webmaster","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-three-principles-that-redux-follows\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-three-principles-that-redux-follows\/","name":"What are the three principles that Redux follows ? - ReactJS - Wikitechy","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-three-principles-that-redux-follows\/#primaryimage"},"image":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-three-principles-that-redux-follows\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/react-redux.png","datePublished":"2022-03-28T06:53:26+00:00","dateModified":"2022-05-04T05:31:14+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4"},"description":"What are the three principles that Redux follows ? - Redux is one of the most trending libraries for front-end development in today\u2019s marketplace.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-three-principles-that-redux-follows\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-three-principles-that-redux-follows\/#primaryimage","url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/react-redux.png","contentUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/react-redux.png","width":859,"height":528},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4","name":"webmaster","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","caption":"webmaster"},"sameAs":["https:\/\/www.wikitechy.com\/interview-questions"],"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4017","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=4017"}],"version-history":[{"count":4,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4017\/revisions"}],"predecessor-version":[{"id":4267,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4017\/revisions\/4267"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=4017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=4017"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=4017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}