Chapter 7: Use Case Scenario 1 – Zustand
So far, we have been exploring some basic patterns we can use to implement a global state in React. In this chapter, we will learn about a real implementation that is publicly available as a package, called Zustand.
Zustand (https://github.com/pmndrs/zustand) is a tiny library primarily designed to create module state for React. It's based on an immutable update model, in which state objects can't be modified but always have to be newly created. Render optimization is done manually using selectors. It has a straightforward and yet powerful store
creator interface.
In this chapter, we will explore how module state and subscriptions are used and see what the library API looks like.
In this chapter, we will cover the following topics:
- Understanding module state and immutable state
- Adding React hooks to optimize re-renders
- Working with read state and update state
- Handling structured data
- Pros and...