The Zustand API [from the React Spring guys] is amazing and clean:
1) Use create(<callback to build>) to build a store, initialize state, and get a hook associated with that store
2) Use the hook (eg useStore(<query selector>)) to query/select data from the store.
Whenever that data slice changes, the hook re-emits and the component can re-render with up-to-date state.
The Zustand API [from the React Spring guys] is amazing and clean:
1) Use
create(<callback to build>)
to build a store, initialize state, and get a hook associated with that store2) Use the hook (eg
useStore(<query selector>)
) to query/select data from the store.Whenever that data slice changes, the hook re-emits and the component can re-render with up-to-date state.
@see github.com/pmndrs/zustand