What is Redux?

A javascript state management library that is usually used in Redux. It allows for all of the app's state to be utilized anywhere in the app.

3 Principles of REDUX

The following principles do not use any redux 'magic.' They can all be utilized using plain javascript.

Using these three principles allow us to know exactly where and how the state changes. It also allows us to use the state in any part of the app.

1. There is one and only one source of truth for the app

There is only one state tree in an app. That state tree is stored in a plain javascript object. That object is then the single source for everything that is happening in the app.

2. State is read only

The state object is a constant and cannot be modified without an action to indicate what is being changed. An action is a plain javascript object that contains a type key value pair. An action describes how the state will change. By using an action to describe changes, we know exactly what is happening in the app when changes occur.

3. State can only be modified with reducers

A reducer is a function that takes in two arguments, an action and the previous state, and returns the modified state.

128 0 3