react reducer what



Ok where is the general accepted implementation with react-redux. It is a global / subsection state management that maintain data used in your application. For example, lets say you have a Todo list, you might use, the following objects to keep track of it.

STATE {
- TODO_ID - when user click on ADD_TODO
- TODO_LIST - keep tracks of all your tasks you have created.
}


These are all trigger based on actions. This is why we have to setup actions. Action when someone click "Add Task". Then it sends a certain message - "ADD_TODO' to be specific to a  reducer.

What is a reducer?
Say you have fire up / dispatch / send out a 'ADD_TODO' instruction and you increment current task id with 1. So you can have a unique Id or some way to keep track of it. This is where you pass it to a reducer. You say hey, my ADD_TODO is fired, get me a new TASK_ID.

Reducer is where you are allowed to changes / update state STATE - TODO_ID.

Some other action will update TODO_LIST and so and so....

Then somewhere in time, you call connect() to tie store and action together.









Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm