reading-notes

Reading notes for Code Fellows!


Project maintained by William-Moreno Hosted on GitHub Pages — Theme by mattgraham

Redux - Combined Reducers

Why choose Redux instead of the Context API for global state?

In medium and larger scale apps or apps with more complex states, Redux is much easier to implement and optimize.

What is the purpose of a reducer?

The purpose of a reducer is to receive and interpret actions and then change or update state based on what action was taken.

What does an action contain?

Actions are objects that contain two components, a type and a payload. The type element indicates the type of action being performed. The payload component of an action is any information concerning or concerned by the action that is not specifically its type or status.

Why do we need to copy the state in a reducer?

In Redux, reducers are never allowed to mutate the original or current state values. They can only make copies of the original values and then they can mutate the copies. Reasons for this include:

Redux Docs

Vocabulary Terms

Vocabulary Term Definition
immutable state states which are not allowed to be modified, or mutated, in anyway. Typically, this is achieved by employing values and pure functions.
time travel in redux Time travel debugging refers to the ability step forward and backward through the state of you application, empowering the developer understand exactly what is happening at any point in the app’s lifecycle. gitconnected
action creator a function that returns an action object which would then need to be dispatched.
reducer a function that determines changes to an application’s state. It uses the action it receives to determine this change.
dispatch this is a function in Redux that triggers and ‘action’, which is the only way to implement a state change react-redux

Back to Main