-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Overview
In this note, I will delve into the world of redux toolset for managing global state in React applications. This article covers three parts:
- Redux ecosystem for React applications
- Core concepts in redux
- Good redux practices
Ecosystem packages
- Redux: the state container for redux-based state management app.
- @reduxjs/toolkit: the official, opinionated, batteries-included toolset for efficient Redux development
- react-redux: The lib to combine redux with react.
Core concepts in Redux
1. The single flow of data
Redux implements the single flow of data concept. There are three concepts
- The state, the source of truth that drives our app;
- The view, a declarative description of the UI based on the current state
- The actions, the events that occur in the app based on user input or programmatically triggered, and trigger updates in the state
Through user interaction on the view, an action is triggered, leading to a state change that subsequently updates the user interface.
Derived concepts
2. Action creator and reducer
- action: action creator, a function that creates an action
- reducer : A reducer is a pure function that takes the previous state and an action as inputs, and returns a new state for the view. It's important to note that all operations within a reducer function are performed synchronously.

