github pmndrs/zustand v4.0.0

latest releases: v5.0.0-rc.2, v5.0.0-rc.1, v5.0.0-rc.0...
2 years ago

🎉 🎉 🎉 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 #604
  • breaking(middleware): drop deprecated persist options and make removeItem required by @dai-shi in #598
  • breaking(core): drop v2 hook compatibility by @dai-shi in #597
  • breaking(types): drop deprecated UseStore type by @dai-shi in #596
  • feat: use-sync-external-store by @dai-shi in #550
  • breaking(middleware/devtools): use official devtools extension types by @dai-shi in #819
  • breaking(middleware/devtools): remove deprecations and warnings by @devanshj in #892
  • fix(build): separate vanilla build by @dai-shi in #904
  • breaking(types): Add higher kinded mutator types by @devanshj in #725
  • fix(index): export createStore from vanilla by @dai-shi in #914
  • fix(middleware): separate immer middleware by @dai-shi in #915
  • fix(middleware/devtools): add enabled option and show devtools warning only if enabled by @Aslemammad in #880
  • breaking(middleware/devtools): remove checking old string option by @dai-shi in #933
  • Fix TS4023 and other minor changes by @devanshj in #940
  • fix(types): avoid any in react.ts by @dai-shi in #941
  • fix(build): add downlevel-dts by @dai-shi in #1005
  • refactor: prefer interfaces by @dai-shi in #1012
  • fix(types): Mark more methods bivariant by @RyanCavanaugh in #1029
  • fix(types): remove Partial typo from persist by @devanshj in #1051
  • fix(shallow): restrict types by @dai-shi in #1070
  • feature(persist): add method getOptions on persist api and update documentation by @tbor00 in #1075
  • feat(types): minimize types by deprecating them by @devanshj in #1089
  • fix(build): a workaround for ESM for use-sync-external-store by @dai-shi in #953
  • fix(types): use TS interfaces only for public api by @dai-shi in #1106
  • fix(shallow): types with useStore by @dai-shi in #1108
  • fix(shallow): types with useStore again by @dai-shi in #1117
  • refactor(types): avoid using deprecated types by @dai-shi in #1122

New Contributors

Full Changelog: v3.7.2...v4.0.0

Don't miss a new zustand release

NewReleases is sending notifications on new releases.