Why subscribe doesn't work with zustand?

why when state gets update subscribe doesn't work?
const useCartStore = create(subscribeWithSelector(cartStore))

useCartStore.subscribe(
  state => state.food,
  food => {
    console.log(202)
    if (typeof window === "undefined") return
    const storage = getStorage()
    storage.saveFood(food)
  },
)

export default useCartStore

I expect - when I change state.food - I got console log 202
Was this page helpful?