Usage of Updating multiple stores
MilesLeeeeee opened this issue · comments
Summary
Hello,I tried to use the Slices pattern following the documentation
Updating multiple stores seems inconsistent with actual usage
i found a way from #2045
It seems that using get() is correct?
Link to reproduction
https://codesandbox.io/s/recursing-proskuriakova-qmyz2n?file=/store/zustand.ts
@MilesLeeeeee the usage of create slice functions inside of actions is wrong. You should always use get
.
Note: since you want to use get state in your create slice function you should pass
set
andget
not onlyset
. For instance: instead ofcreateFishSlice(set)
should becreateFishSlice(set, get)
orcreateFishSlice(...a)
@dai-shi seems that zustand docs page is outdated, would you mind deploying the latest version?
@dbritto-dev yes,Using get() is right, thanks a lot !!!