The conditional watchers pattern is an underappreciated design choice — most custom store implementations skip this and force consumers to filter changes in their own useEffect hooks, which scatters subscription logic across components. One consideration worth adding: memory leak prevention when components unmount mid-subscription, especially if the watcher holds a closure over stale state. That cleanup path is where most custom stores silently break in production.
Building it yourself first is genuinely the best way to understand why Zustand or Jotai make the tradeoffs they do. The point about performance optimization and having precise control over rendering behaviour is one that gets overlooked when you just reach for the popular library without questioning it.
Thanks for the great article and discussion about how one may implement their own state management in React!
Fabio Sarmento
Artificial Intelligence
Your emphasis on the educational value of building custom state management solutions is spot on. For instance, I once implemented a lightweight custom store for a project with specific real-time data requirements. This not only improved performance by preventing unnecessary re-renders but also deepened my understanding of how state transitions work, which proved invaluable when adapting existing libraries for other projects.