React and Redux

React and Redux

Most important words in Redux architecture:

  • Store
  • Dispatch
  • Actions
  • Reducer
  • State

Store

??


Reducer

Reducer is a function that recieves two parameters and returns a piece of the application state.

The first parameter is the current state, and the second is the action

1
2
3
function counter(currentState, action) {
  var DEFAULT_STATE = { count: 0, sum: 0};
}

Dispatch

Is a function that returns an action. Returns an object with the type property and can return extra data if necessary.


State

State is an object managed by STATE.

5
6
// this will return the state object from store
var state = store.getState();

Action


Container (Smart Component)

Container is a react component that as a direct connection to the state managed by redux.