Mastering Redux with Redux toolkit, write a correct redux!
Redux is a popular state management library, used by numerous enterprise companies. Although many articles are against Redux because of the useContext
or other minimalize libraries such as Zustand, Jaltio, etc. However, personally, I still think learning Redux will benefit us as a Frontend engineer, especially when it’s the most popular and most used by a lot of big companies.
Table of content
- Introduction
- Terminology
- How it works
- Redux toolkit introduction
- Example in a real app
Introduction
Let’s start with understanding what Redux is and its purpose of it. Basically, Redux is a library to manage global state in an application. Previously, there’s a lot of problems with how components can share their local state with others. This is where Redux comes to help. In the official document Here, you only need Redux if and only if your application has a medium to large codebase, the global shared state is complex, and frequent updates happening. If it’s not the case, I think React useContext is more than enough. Just remember that there’s no rendering optimization in useContext
. You need to be careful structuring your context hook to prevent any…