note: la sintesi e le note di rilascio sono in inglese
warning: intervento richiesto
9 breaking changes4 punti chiave
Zustand v5 adds no new features but drops many old APIs, so upgrading needs the migration guide.
breaking changestutte citate, ognuna con una soluzione
breaking[2]: Deprecated features are removed.
Drop deprecated features
help: Follow the migration guide linked in the release notes.
breaking[3]: React 18 becomes the minimum required version.
Make React 18 the minimum required version
help: Upgrade React to version 18 or newer before upgrading Zustand.
breaking[4]: TypeScript 4.5 becomes the minimum required version.
Make TypeScript 4.5 the minimum required version
help: Upgrade TypeScript to version 4.5 or newer.
breaking[5]: UMD and SystemJS support is dropped.
Drop UMD/SystemJS support
help: Follow the migration guide linked in the release notes.
breaking[6]: ES5 support is dropped.
breaking[7]: Types are stricter when setState's replace flag is set.
Stricter types when setState's replace flag is set
help: Check your setState calls that use the replace flag for type errors.
breaking[8]: The persist middleware behaves differently.
Persist middleware behavioral change
help: Check your persist middleware usage against the migration guide linked in the release notes.
breaking[9]: Other small improvements include changes that are technically breaking.
Other small improvements (technically breaking changes)
help: Check the migration guide linked in the release notes for details.
punti chiave
- note[1]: The release adds no new features and mainly removes old things.release-notes:5
- note[2]: React 18 is now the minimum required version.release-notes:13
- note[3]: An infinite loop error from v4 now appears as an explicit error, and
useShallowoften fixes it.release-notes:35 - note[4]: Immer type inference for
setStateis fixed.release-notes:39
release-notesgithub.com/pmndrs/zustand · 58 righe
- # 🎉🎉🎉 Zustand v5 🐻🐻🐻
- ## TL;DR
- - No new features
- - Drop many old things
- - Migration from v4 should be smooth.
- ## Changes in v5
- - Drop default exports
- - Drop deprecated features
- - Make React 18 the minimum required version
- - Make use-sync-external-store a peer dependency (required for `createWithEqualityFn` and `useStoreWithEqualityFn` in `zustand/traditional`)
- - Make TypeScript 4.5 the minimum required version
- - Drop UMD/SystemJS support
- - Organize entry points in the package.json
- - Drop ES5 support
- - Stricter types when setState's replace flag is set
- - Persist middleware behavioral change
- - Other small improvements (technically breaking changes)
- ## Migration Guide
- Read the migration guide carefully:
- https://github.com/pmndrs/zustand/blob/main/docs/migrations/migrating-to-v5.md
- ### Frequently Reported Issue
- During the RC period, some users encountered the following infinite loop error:
- ```
- Uncaught Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.
- ```
- This case was already a non-ideal behavior in v4 but appears more explicitly as an error in v5. While there are several ways to resolve this, using `useShallow` often fixes the problem.
- ## What's Changed
- * v5 by @dai-shi in https://github.com/pmndrs/zustand/pull/2138
- * Fix Immer type inference for `setState` by @chrisvander in https://github.com/pmndrs/zustand/pull/2696
- ## New Contributors
- * @abernier made their first contribution in https://github.com/pmndrs/zustand/pull/2674
- * @tthallos made their first contribution in https://github.com/pmndrs/zustand/pull/2501
- * @sagiereder made their first contribution in https://github.com/pmndrs/zustand/pull/2673
- * @melutovich made their first contribution in https://github.com/pmndrs/zustand/pull/2692
- * @rgksugan made their first contribution in https://github.com/pmndrs/zustand/pull/2695
- * @Anuovec made their first contribution in https://github.com/pmndrs/zustand/pull/2708
- * @EthanRBrown made their first contribution in https://github.com/pmndrs/zustand/pull/2717
- * @mym0404 made their first contribution in https://github.com/pmndrs/zustand/pull/2730
- * @87xie made their first contribution in https://github.com/pmndrs/zustand/pull/2745
- * @f312213213 made their first contribution in https://github.com/pmndrs/zustand/pull/2761
- * @DanThemes made their first contribution in https://github.com/pmndrs/zustand/pull/2764
- * @chaficnajjar made their first contribution in https://github.com/pmndrs/zustand/pull/2770
- * @goosewobbler made their first contribution in https://github.com/pmndrs/zustand/pull/2781
- * @Amyssyko made their first contribution in https://github.com/pmndrs/zustand/pull/2784
- * @MartinGamesCZ made their first contribution in https://github.com/pmndrs/zustand/pull/2785
- **Full Changelog**: https://github.com/pmndrs/zustand/compare/v4.5.5...v5.0.0