v4.0.0
版本发布时间: 2022-07-26 09:31:27
pmndrs/zustand最新发布版本:v5.0.0-rc.2(2024-09-15 11:17:18)
🎉 🎉 🎉 Zustand v4 is here 🎉 🎉 🎉
Backward compatible with v3 in JS
v4 API is completely backward compatible, so it's just nothing to update if you are JS users.
One note is v4 depends on use-sync-external-store. There might be some bundling issues. Please report them if you encounter such cases.
TypeScript types are rewritten
To better support types with middleware, v4 TypeScript code is rewritten. Please find docs/typescript.md for more information.
New API for context usage
In v3, zustand/context
is provided as a workaround.
v4 API exposes createStore
and useStore
, which are more flexible.
Please read this for usage.
If you are unsure about the usage, open a new discussion.
Counter example: https://codesandbox.io/s/polished-pond-4jn1e2
Deprecated APIs are removed
Some APIs are already deprecated in v3, and they are removed in v4. Please make sure to update to the latest version of v3 before migrating to v4.
What's Changed
- breaking(vanilla): drop deprecated store.subscribe with selector by @dai-shi in https://github.com/pmndrs/zustand/pull/604
- breaking(middleware): drop deprecated persist options and make removeItem required by @dai-shi in https://github.com/pmndrs/zustand/pull/598
- breaking(core): drop v2 hook compatibility by @dai-shi in https://github.com/pmndrs/zustand/pull/597
- breaking(types): drop deprecated UseStore type by @dai-shi in https://github.com/pmndrs/zustand/pull/596
- feat: use-sync-external-store by @dai-shi in https://github.com/pmndrs/zustand/pull/550
- breaking(middleware/devtools): use official devtools extension types by @dai-shi in https://github.com/pmndrs/zustand/pull/819
- breaking(middleware/devtools): remove deprecations and warnings by @devanshj in https://github.com/pmndrs/zustand/pull/892
- fix(build): separate vanilla build by @dai-shi in https://github.com/pmndrs/zustand/pull/904
- breaking(types): Add higher kinded mutator types by @devanshj in https://github.com/pmndrs/zustand/pull/725
- fix(index): export createStore from vanilla by @dai-shi in https://github.com/pmndrs/zustand/pull/914
- fix(middleware): separate immer middleware by @dai-shi in https://github.com/pmndrs/zustand/pull/915
- fix(middleware/devtools): add
enabled
option and show devtools warning only if enabled by @Aslemammad in https://github.com/pmndrs/zustand/pull/880 - breaking(middleware/devtools): remove checking old string option by @dai-shi in https://github.com/pmndrs/zustand/pull/933
- Fix TS4023 and other minor changes by @devanshj in https://github.com/pmndrs/zustand/pull/940
- fix(types): avoid any in react.ts by @dai-shi in https://github.com/pmndrs/zustand/pull/941
- fix(build): add downlevel-dts by @dai-shi in https://github.com/pmndrs/zustand/pull/1005
- refactor: prefer interfaces by @dai-shi in https://github.com/pmndrs/zustand/pull/1012
- fix(types): Mark more methods bivariant by @RyanCavanaugh in https://github.com/pmndrs/zustand/pull/1029
- fix(types): remove
Partial
typo frompersist
by @devanshj in https://github.com/pmndrs/zustand/pull/1051 - fix(shallow): restrict types by @dai-shi in https://github.com/pmndrs/zustand/pull/1070
- feature(persist): add method getOptions on persist api and update documentation by @tbor00 in https://github.com/pmndrs/zustand/pull/1075
- feat(types): minimize types by deprecating them by @devanshj in https://github.com/pmndrs/zustand/pull/1089
- fix(build): a workaround for ESM for use-sync-external-store by @dai-shi in https://github.com/pmndrs/zustand/pull/953
- fix(types): use TS interfaces only for public api by @dai-shi in https://github.com/pmndrs/zustand/pull/1106
- fix(shallow): types with useStore by @dai-shi in https://github.com/pmndrs/zustand/pull/1108
- fix(shallow): types with useStore again by @dai-shi in https://github.com/pmndrs/zustand/pull/1117
- refactor(types): avoid using deprecated types by @dai-shi in https://github.com/pmndrs/zustand/pull/1122
New Contributors
- @piotr-cz made their first contribution in https://github.com/pmndrs/zustand/pull/927
- @mahendradambe made their first contribution in https://github.com/pmndrs/zustand/pull/956
- @Himself65 made their first contribution in https://github.com/pmndrs/zustand/pull/978
- @jenglamlow made their first contribution in https://github.com/pmndrs/zustand/pull/988
- @InfiniteXyy made their first contribution in https://github.com/pmndrs/zustand/pull/1006
- @guilleon-velasco made their first contribution in https://github.com/pmndrs/zustand/pull/1009
- @sepehr-safari made their first contribution in https://github.com/pmndrs/zustand/pull/1049
- @rnike made their first contribution in https://github.com/pmndrs/zustand/pull/1056
- @tbor00 made their first contribution in https://github.com/pmndrs/zustand/pull/1071
- @Carnageous made their first contribution in https://github.com/pmndrs/zustand/pull/1057
- @xlboy made their first contribution in https://github.com/pmndrs/zustand/pull/1082
- @RyanCavanaugh made their first contribution in https://github.com/pmndrs/zustand/pull/1029
- @Gabriel-Alves-Cunha made their first contribution in https://github.com/pmndrs/zustand/pull/997
- @chann44 made their first contribution in https://github.com/pmndrs/zustand/pull/1016
Full Changelog: https://github.com/pmndrs/zustand/compare/v3.7.2...v4.0.0