Software Development

What is the best way to handle global state management in modern JavaScript without Redux?

DA Asked by David Robinson · 22-09-2023
0 upvotes 8,770 views 0 comments
The question

We are looking to move away from Redux due to the heavy boilerplate code. What are the most reliable alternatives currently being used in professional environments? I have heard about Zustand and the Context API, but I am worried about performance issues during frequent re-renders in large apps. 

3 answers

0
JE
Answered on 24-09-2023

Zustand has become a favorite in the community because it is lightweight and doesn't wrap your entire app in providers, which solves many of the re-render issues found in the Context API. For very large, data-heavy applications, TanStack Query (React Query) is actually a better "state" manager for server data, while Zustand handles your local UI state. This separation of concerns significantly reduces complexity compared to the old Redux patterns. Many teams find that they don't even need a dedicated global state manager once they start using these specialized tools correctly for their data. 

0
RO
Answered on 26-09-2023

Are you specifically seeing performance bottlenecks with the Context API, or are you just trying to follow the trend of moving away from Redux? 

T 27-09-2023

Robert, many developers find that the Context API causes unnecessary re-renders in large component trees because it doesn't have built-in selectors like Zustand or Redux. This forces parts of the UI to update even when the specific data they consume hasn't changed.

0
B
Answered on 28-09-2023

Zustand is definitely the way to go for simplicity and performance. It has a very small footprint and is easy to learn for new team members. 

DA 29-09-2023

Totally agree with Barbara; the lack of boilerplate makes the code much more readable and maintainable for long-term projects.

Share your thoughts

Your email address will not be published. Required fields are marked (*)

Professional Counselling Session

Still have questions?
Schedule a free counselling session

Our experts are ready to help you with any questions about courses, admissions, or career paths. Get personalized guidance from industry professionals.

Request a Call Back

Search Online

We Accept

We Accept

Follow Us

"PMI®", "PMBOK®", "PMP®", "CAPM®" and "PMI-ACP®" are registered marks of the Project Management Institute, Inc. | "CSM", "CST" are Registered Trade Marks of The Scrum Alliance, USA. | COBIT® is a trademark of ISACA® registered in the United States and other countries.

Book Free Session