Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

First Steps and creating the Redux Store

So in our example, we will try to write the code for accomplishing the family balance example we had before. 

At this point you must learn that redux is not strictly connected with react or with any other framework for that matter. Is completely an independent software. 

For our example now, we will focus solely on redux and how redux works apart from react. This will make us understand it's core basics really easier and faster. The main functionality of redux can be applied later alongside with any framework of our choice.

Later on, we will implement the same example by using react as a framework and redux as a state management and we will connect the two of them. But for now let's focus solely on Redux and execute it from node.js.

Create a new project folder, and initialize an npm repository there. 

Then install redux by typing: npm install --save redux

After you have installed it's time to create our only file named redux.js and import redux with the node.js style at the top of it.

The first thing we need to do, is to actually create a redux store. This is going to be the place that will hold, not only the state, but also the functionality for changing and updating the state, the necessary actions that will have to be dispatched and many more.

We create a new store by using the redux's createStore function that accepts one parameter. This is going to be the reducer function (or the manager, or the father in our case) as it shown above.

The next step is to actually implement the reducer function, but for now we will take a step aside and we will create the actions. Later we will implement the reducer function.