REDUX

"Redux is a predictable state container for JavaScript apps"

Three Principles

  • Single source of truth (store)

  • State is read-only (actions)

  • Changes are made with pure functions (reducers)

The main "characters"

  • Actions

  • Reducers

  • THE Store

Actions

{
  type: 'ADD_TODO',
  text: 'Build my first Redux app'
}

Reducers

function reducer(previousState, action) {
    return newState;
}

Store

  • Is an object that brings the actions and reducers together

  • Holds the state of the application

  • Allows state to be updated via dispatch(action)

  • Registers listeners via subscribe(listener)

Data-flow

Redux Intro

By Alin Chiuaru

Redux Intro

  • 24