DEV Community

Discussion on: Optimizing Zustand: How to Prevent Unnecessary Re-renders in Your React App

Collapse
 
sven1106 profile image
Sven1106

Just out of curiosity, is there a specific reason why you created this instead of using react-tracked :)

Collapse
 
eraywebdev profile image
Eray Kaya

Hey, I wasn't aware of react-tracked; it looks interesting. However, I wouldn't consider using it in production for a couple of reasons:

  • The last published date is 9 months ago, which raises concerns about its maintenance and compatibility with newer versions of zustand.

  • Let's say I'm already using Zustand for managing global state in my project. If I decide to upgrade to a newer version of Zustand, I only need to consider that library. Adding another dependency like react-tracked introduces unnecessary complexity. This might not be a big issue for smaller hobby projects, but for larger projects with 50+ stores or slices, it becomes a concern.

While it's true that we shouldn't reinvent the wheel, there's a balance to strike. We should avoid adding a new library for every single detail. What I've implemented here can be achieved without creating an additional dependency, which keeps things more streamlined in my opinion.