reboottime / WebDevelopment

Some notes, thoughts and articles aggregated here about UI/UX and web development.
6 stars 0 forks source link

Managing State in React: Exploring Redux 8.x Features #32

Open reboottime opened 1 year ago

reboottime commented 1 year ago

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:


Ecosystem packages


Core concepts in Redux

1. The single flow of data

Redux implements the single flow of data concept. There are three concepts

Through user interaction on the view, an action is triggered, leading to a state change that subsequently updates the user interface.

image

Derived concepts

2. Action creator and reducer


reboottime commented 1 year ago

Project structure and naming conventions

1. createSlice

Before the advent of the redux toolkit, managing action types and breaking down a large global state into manageable, cohesive modules was a common challenge faced by many.

The introduction of the Redux Toolkit has proposed a standardized way for modularizing and generating Redux components, exemplified in this Gist. Here are a few key benefits of using the toolkit:

export const store = configureStore({
  reducer: counterSlice.reducer,
})

2. Project structure

Redux-related files are organized under the redux folder and named after the respective features they represent.

For a suggested example, please refer to this link.