-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(middleware/persist): improve createJSONStorage for Maps #1763
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit c9c7a98:
|
Hi, thanks for suggestion. So, the general suggestion is to provide an alternative function to That said, what would be acceptable is to let Would you like to work on it? You would still like to create a third-party package that supports Maps out of the box. |
Hey, thanks for the answer! Alright, makes sense to me. Just to double check if I understand correctly: What I would do now is to
Please let me know if those steps make sense for you, and if you want me to even do the third step. If not there would then be the question if and how I should test the options parameter 🤔 |
@lauhon |
@lauhon Hi, just wondering how you are doing. No rush, but hope to have the update soon. |
Hey @dai-shi, thanks for the push. Was a couple of busy days for me :) Not sure if its in your interest what i did in the tests. Looking forward to your review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me. Added some comments.
src/middleware/persist.ts
Outdated
reviver: (key: string, value: unknown) => unknown | ||
replacer: (key: string, value: unknown) => unknown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can make these optional:
reviver: (key: string, value: unknown) => unknown | |
replacer: (key: string, value: unknown) => unknown | |
reviver?: (key: string, value: unknown) => unknown | |
replacer?: (key: string, value: unknown) => unknown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
tests/persistAsync.test.tsx
Outdated
count: 42, | ||
name, | ||
map: { type: 'Map', value: [['foo', 'bar']] }, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you create a new test case for Map and keep existing tests unmodified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, i pretty much copied the old persist- and rehyadrate tests and changed it to persist and rehydrate a map, I hope thats fine
tests/persistAsync.test.tsx
Outdated
import { afterEach, describe, expect, it, jest } from '@jest/globals' | ||
import { act, render, waitFor } from '@testing-library/react' | ||
import { StrictMode, useEffect } from 'react' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check lint errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution!
I think in the same way we could serialize / deserialize function replacer(key: string, value: any) {
if (value instanceof Map) {
return { __type: "Map", value: Object.fromEntries(value) };
}
if (value instanceof Set) {
return { __type: "Set", value: Array.from(value) };
}
return value;
}
function reviver(key: string, value: any) {
if (value?.__type === "Map") {
return new Map(Object.entries(value.value));
}
if (value?.__type === "Set") {
return new Set(value.value);
}
return value;
}
export function createEnhancedJSONStorage<S>(
getStorage: () => StateStorage
): PersistStorage<S> | undefined {
let storage: StateStorage | undefined;
try {
storage = getStorage();
} catch (e) {
// prevent error if the storage is not defined (e.g. when server side rendering a page)
return;
}
const persistStorage: PersistStorage<S> = {
getItem: (name) => {
const parse = (str: string | null) => {
if (str === null) {
return null;
}
return JSON.parse(str, reviver) as StorageValue<S>;
};
const str = (storage as StateStorage).getItem(name) ?? null;
if (str instanceof Promise) {
return str.then(parse);
}
return parse(str);
},
setItem: (name, newValue) =>
(storage as StateStorage).setItem(
name,
JSON.stringify(newValue, replacer)
),
removeItem: (name) => (storage as StateStorage).removeItem(name),
};
return persistStorage;
} |
Yes, and my point is that supporting things are out of the scope of Zustand library. |
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@types/node](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node) ([source](https://togithub.com/DefinitelyTyped/DefinitelyTyped)) | [`^18.16.2` -> `^18.16.6`](https://renovatebot.com/diffs/npm/@types%2fnode/18.16.3/18.16.6) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | | [@types/react](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react) ([source](https://togithub.com/DefinitelyTyped/DefinitelyTyped)) | [`^18.2.0` -> `^18.2.6`](https://renovatebot.com/diffs/npm/@types%2freact/18.2.0/18.2.6) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | | [@types/react-dom](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-dom) ([source](https://togithub.com/DefinitelyTyped/DefinitelyTyped)) | [`^18.2.1` -> `^18.2.4`](https://renovatebot.com/diffs/npm/@types%2freact-dom/18.2.1/18.2.4) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | | [eslint](https://eslint.org) ([source](https://togithub.com/eslint/eslint)) | [`^8.39.0` -> `^8.40.0`](https://renovatebot.com/diffs/npm/eslint/8.39.0/8.40.0) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | | [vite](https://togithub.com/vitejs/vite/tree/main/#readme) ([source](https://togithub.com/vitejs/vite)) | [`^4.3.3` -> `^4.3.5`](https://renovatebot.com/diffs/npm/vite/4.3.3/4.3.5) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | | [zustand](https://togithub.com/pmndrs/zustand) | [`^4.3.7` -> `^4.3.8`](https://renovatebot.com/diffs/npm/zustand/4.3.7/4.3.8) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>eslint/eslint</summary> ### [`v8.40.0`](https://togithub.com/eslint/eslint/releases/tag/v8.40.0) [Compare Source](https://togithub.com/eslint/eslint/compare/v8.39.0...v8.40.0) #### Features - [`5db7808`](https://togithub.com/eslint/eslint/commit/5db7808139c1f2172797285a0700f01644bda254) feat: improve flat config errors for invalid rule options and severities ([#​17140](https://togithub.com/eslint/eslint/issues/17140)) (Josh Goldberg ✨) - [`f5574dc`](https://togithub.com/eslint/eslint/commit/f5574dc739fcc74a7841217ba1f31cce02bee1ff) feat: Add findConfigFile() method to FlatESLint ([#​17142](https://togithub.com/eslint/eslint/issues/17142)) (Nicholas C. Zakas) - [`e52b98b`](https://togithub.com/eslint/eslint/commit/e52b98bf25d882da4efd5559ce5974b6697cf701) feat: add `sourceCode` property to the rule context ([#​17107](https://togithub.com/eslint/eslint/issues/17107)) (Nitin Kumar) - [`1468f5b`](https://togithub.com/eslint/eslint/commit/1468f5b640cfa6fdd8a5ec895337f692def2780b) feat: add `physicalFilename` property to the rule context ([#​17111](https://togithub.com/eslint/eslint/issues/17111)) (Nitin Kumar) - [`0df4d4f`](https://togithub.com/eslint/eslint/commit/0df4d4f658c214e51310a986c03d44d34ceae3ec) feat: add `cwd` to rule context ([#​17106](https://togithub.com/eslint/eslint/issues/17106)) (Nitin Kumar) - [`52018f2`](https://togithub.com/eslint/eslint/commit/52018f21c19b3e461cae32843cddd17ed42f19cd) feat: add `filename` property to the rule context ([#​17108](https://togithub.com/eslint/eslint/issues/17108)) (Nitin Kumar) - [`559ff4e`](https://togithub.com/eslint/eslint/commit/559ff4e4bc54a8b6e6b54825d83c532d724204b3) feat: add new `omitLastInOneLineClassBody` option to the `semi` rule ([#​17105](https://togithub.com/eslint/eslint/issues/17105)) (Nitin Kumar) #### Bug Fixes - [`f076e54`](https://togithub.com/eslint/eslint/commit/f076e54ecdb0fae70d9b43ad6888606097beef97) fix: Ensure FlatESLint#findConfigFile() doesn't throw. ([#​17151](https://togithub.com/eslint/eslint/issues/17151)) (Nicholas C. Zakas) #### Documentation - [`e980bf3`](https://togithub.com/eslint/eslint/commit/e980bf38cf441f2eb29c458b93df77dc0111b391) docs: Update README (GitHub Actions Bot) - [`e92a6fc`](https://togithub.com/eslint/eslint/commit/e92a6fc7ed2a427f5e95f4b3a1c21d71553c97ee) docs: Update README (GitHub Actions Bot) - [`af5fe64`](https://togithub.com/eslint/eslint/commit/af5fe64c398c9bd4206c3c6c1ade81768b291031) docs: Fix custom rule schema docs ([#​17115](https://togithub.com/eslint/eslint/issues/17115)) (Adam Jones) - [`4a352a9`](https://togithub.com/eslint/eslint/commit/4a352a957ba9e721bec9f6f403b419a22b0ec423) docs: explain how to include predefined globals ([#​17114](https://togithub.com/eslint/eslint/issues/17114)) (Marcus Wyatt) - [`5ea15d9`](https://togithub.com/eslint/eslint/commit/5ea15d92ee358e8f3f652c94c019cac96aaec651) docs: add mastodon link in readme ([#​17110](https://togithub.com/eslint/eslint/issues/17110)) (唯然) #### Chores - [`4053004`](https://togithub.com/eslint/eslint/commit/4053004c951813473d1c43f9f9959a9a3484242f) chore: upgrade [@​eslint/js](https://togithub.com/eslint/js)[@​8](https://togithub.com/8).40.0 ([#​17156](https://togithub.com/eslint/eslint/issues/17156)) (Milos Djermanovic) - [`50fed1d`](https://togithub.com/eslint/eslint/commit/50fed1da4449ad7ecbb558294438273cfce603d4) chore: package.json update for [@​eslint/js](https://togithub.com/eslint/js) release (ESLint Jenkins) - [`4c7a170`](https://togithub.com/eslint/eslint/commit/4c7a170b04c5a746e401bef7ce79766ff66a1168) chore: upgrade [@​eslint/eslintrc](https://togithub.com/eslint/eslintrc)[@​2](https://togithub.com/2).0.3 ([#​17155](https://togithub.com/eslint/eslint/issues/17155)) (Milos Djermanovic) - [`e80b7cc`](https://togithub.com/eslint/eslint/commit/e80b7cce640b60c00802148dbb51d03c7223afa9) chore: upgrade [email protected] ([#​17154](https://togithub.com/eslint/eslint/issues/17154)) (Milos Djermanovic) - [`ce3ac91`](https://togithub.com/eslint/eslint/commit/ce3ac91b510576e2afba1657aa5f09e162b4ab07) chore: upgrade [email protected] ([#​17153](https://togithub.com/eslint/eslint/issues/17153)) (Milos Djermanovic) - [`9094d79`](https://togithub.com/eslint/eslint/commit/9094d79fb42c0ebb6100426a3f2f851e8d42a0ee) chore: add `latest/` to `meta.docs.url` in all core rules ([#​17136](https://togithub.com/eslint/eslint/issues/17136)) (Milos Djermanovic) - [`d85efad`](https://togithub.com/eslint/eslint/commit/d85efad655deacc0dc3fdbbace33307094c3b91b) perf: don't use `grapheme-splitter` on ASCII strings in key-spacing rule ([#​17122](https://togithub.com/eslint/eslint/issues/17122)) (Milos Djermanovic) </details> <details> <summary>vitejs/vite</summary> ### [`v4.3.5`](https://togithub.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small435-2023-05-05-small) [Compare Source](https://togithub.com/vitejs/vite/compare/v4.3.4...v4.3.5) - fix: location is not defined error in cleanScssBugUrl ([#​13100](https://togithub.com/vitejs/vite/issues/13100)) ([91d7b67](https://togithub.com/vitejs/vite/commit/91d7b67)), closes [#​13100](https://togithub.com/vitejs/vite/issues/13100) - fix: unwrapId and pass ssr flag when adding to moduleGraph in this.load ([#​13083](https://togithub.com/vitejs/vite/issues/13083)) ([9041e19](https://togithub.com/vitejs/vite/commit/9041e19)), closes [#​13083](https://togithub.com/vitejs/vite/issues/13083) - fix(assetImportMetaUrl): reserve dynamic template literal query params ([#​13034](https://togithub.com/vitejs/vite/issues/13034)) ([7089528](https://togithub.com/vitejs/vite/commit/7089528)), closes [#​13034](https://togithub.com/vitejs/vite/issues/13034) - fix(debug): skip filter object args ([#​13098](https://togithub.com/vitejs/vite/issues/13098)) ([d95a9af](https://togithub.com/vitejs/vite/commit/d95a9af)), closes [#​13098](https://togithub.com/vitejs/vite/issues/13098) - fix(scan): handle html script tag attributes that contain ">" ([#​13101](https://togithub.com/vitejs/vite/issues/13101)) ([8a37de6](https://togithub.com/vitejs/vite/commit/8a37de6)), closes [#​13101](https://togithub.com/vitejs/vite/issues/13101) - fix(ssr): ignore \__esModule for ssrExportAll ([#​13084](https://togithub.com/vitejs/vite/issues/13084)) ([8a8ea1d](https://togithub.com/vitejs/vite/commit/8a8ea1d)), closes [#​13084](https://togithub.com/vitejs/vite/issues/13084) ### [`v4.3.4`](https://togithub.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small434-2023-05-02-small) [Compare Source](https://togithub.com/vitejs/vite/compare/v4.3.3...v4.3.4) - fix(define): incorrect raw expression value type in build ([#​13003](https://togithub.com/vitejs/vite/issues/13003)) ([8f4cf07](https://togithub.com/vitejs/vite/commit/8f4cf07)), closes [#​13003](https://togithub.com/vitejs/vite/issues/13003) - fix(importAnalysisBuild): support parsing '**VITE_PRELOAD**' ([#​13023](https://togithub.com/vitejs/vite/issues/13023)) ([447df7c](https://togithub.com/vitejs/vite/commit/447df7c)), closes [#​13023](https://togithub.com/vitejs/vite/issues/13023) - fix(server): should respect hmr port when middlewareMode=false ([#​13040](https://togithub.com/vitejs/vite/issues/13040)) ([1ee0014](https://togithub.com/vitejs/vite/commit/1ee0014)), closes [#​13040](https://togithub.com/vitejs/vite/issues/13040) - fix(ssr): track for statements as block scope ([#​13021](https://togithub.com/vitejs/vite/issues/13021)) ([2f8502f](https://togithub.com/vitejs/vite/commit/2f8502f)), closes [#​13021](https://togithub.com/vitejs/vite/issues/13021) - chore: add changelog for vite 4.2.2 and 3.2.6 ([#​13055](https://togithub.com/vitejs/vite/issues/13055)) ([0c9f1f4](https://togithub.com/vitejs/vite/commit/0c9f1f4)), closes [#​13055](https://togithub.com/vitejs/vite/issues/13055) </details> <details> <summary>pmndrs/zustand</summary> ### [`v4.3.8`](https://togithub.com/pmndrs/zustand/releases/tag/v4.3.8) [Compare Source](https://togithub.com/pmndrs/zustand/compare/v4.3.7...v4.3.8) For persist middleware, a new option for createJSONStorage in introduced to support more cases. Note that createJSONStorage isn't a required function (and it's not very recommended as it's not type safe), and one should create a custom storage for more use cases. ##### What's Changed - chore: add extension in imports by [@​dai-shi](https://togithub.com/dai-shi) in [https://github.com/pmndrs/zustand/pull/1678](https://togithub.com/pmndrs/zustand/pull/1678) - feat(middleware/persist): improve createJSONStorage for Maps by [@​lauhon](https://togithub.com/lauhon) in [https://github.com/pmndrs/zustand/pull/1763](https://togithub.com/pmndrs/zustand/pull/1763) - chore(tests): migrate to vitest by [@​arjunvegda](https://togithub.com/arjunvegda) in [https://github.com/pmndrs/zustand/pull/1753](https://togithub.com/pmndrs/zustand/pull/1753) ##### New Contributors - [@​JacobWeisenburger](https://togithub.com/JacobWeisenburger) made their first contribution in [https://github.com/pmndrs/zustand/pull/1737](https://togithub.com/pmndrs/zustand/pull/1737) - [@​spacemeowx2](https://togithub.com/spacemeowx2) made their first contribution in [https://github.com/pmndrs/zustand/pull/1742](https://togithub.com/pmndrs/zustand/pull/1742) - [@​arjunvegda](https://togithub.com/arjunvegda) made their first contribution in [https://github.com/pmndrs/zustand/pull/1754](https://togithub.com/pmndrs/zustand/pull/1754) - [@​zc627788](https://togithub.com/zc627788) made their first contribution in [https://github.com/pmndrs/zustand/pull/1752](https://togithub.com/pmndrs/zustand/pull/1752) - [@​arvinxx](https://togithub.com/arvinxx) made their first contribution in [https://github.com/pmndrs/zustand/pull/1758](https://togithub.com/pmndrs/zustand/pull/1758) - [@​SilentFlute](https://togithub.com/SilentFlute) made their first contribution in [https://github.com/pmndrs/zustand/pull/1762](https://togithub.com/pmndrs/zustand/pull/1762) - [@​dannobytes](https://togithub.com/dannobytes) made their first contribution in [https://github.com/pmndrs/zustand/pull/1779](https://togithub.com/pmndrs/zustand/pull/1779) - [@​BLooDBRothER](https://togithub.com/BLooDBRothER) made their first contribution in [https://github.com/pmndrs/zustand/pull/1777](https://togithub.com/pmndrs/zustand/pull/1777) - [@​lauhon](https://togithub.com/lauhon) made their first contribution in [https://github.com/pmndrs/zustand/pull/1763](https://togithub.com/pmndrs/zustand/pull/1763) **Full Changelog**: pmndrs/zustand@v4.3.7...v4.3.8 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on Monday" in timezone Europe/Berlin, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/mheob/ef-calc).
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [zustand](https://togithub.com/pmndrs/zustand) | [`4.3.6` -> `4.3.9`](https://renovatebot.com/diffs/npm/zustand/4.3.6/4.3.9) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>pmndrs/zustand (zustand)</summary> ### [`v4.3.9`](https://togithub.com/pmndrs/zustand/releases/tag/v4.3.9) [Compare Source](https://togithub.com/pmndrs/zustand/compare/v4.3.8...v4.3.9) This includes a small improvement for production build mostly for Vite users. Docs have been improved too! #### What's Changed - fix(build): mode env for "import" condition" by [@​dai-shi](https://togithub.com/dai-shi) in [https://github.com/pmndrs/zustand/pull/1845](https://togithub.com/pmndrs/zustand/pull/1845) #### New Contributors - [@​Debbl](https://togithub.com/Debbl) made their first contribution in [https://github.com/pmndrs/zustand/pull/1792](https://togithub.com/pmndrs/zustand/pull/1792) - [@​Nipodemos](https://togithub.com/Nipodemos) made their first contribution in [https://github.com/pmndrs/zustand/pull/1782](https://togithub.com/pmndrs/zustand/pull/1782) - [@​vadimshvetsov](https://togithub.com/vadimshvetsov) made their first contribution in [https://github.com/pmndrs/zustand/pull/1800](https://togithub.com/pmndrs/zustand/pull/1800) - [@​bobylito](https://togithub.com/bobylito) made their first contribution in [https://github.com/pmndrs/zustand/pull/1810](https://togithub.com/pmndrs/zustand/pull/1810) - [@​celineling](https://togithub.com/celineling) made their first contribution in [https://github.com/pmndrs/zustand/pull/1804](https://togithub.com/pmndrs/zustand/pull/1804) - [@​valerii15298](https://togithub.com/valerii15298) made their first contribution in [https://github.com/pmndrs/zustand/pull/1819](https://togithub.com/pmndrs/zustand/pull/1819) - [@​Hecmatyar](https://togithub.com/Hecmatyar) made their first contribution in [https://github.com/pmndrs/zustand/pull/1816](https://togithub.com/pmndrs/zustand/pull/1816) - [@​203x](https://togithub.com/203x) made their first contribution in [https://github.com/pmndrs/zustand/pull/1826](https://togithub.com/pmndrs/zustand/pull/1826) - [@​Ciensprog](https://togithub.com/Ciensprog) made their first contribution in [https://github.com/pmndrs/zustand/pull/1844](https://togithub.com/pmndrs/zustand/pull/1844) - [@​Romainlg29](https://togithub.com/Romainlg29) made their first contribution in [https://github.com/pmndrs/zustand/pull/1843](https://togithub.com/pmndrs/zustand/pull/1843) - [@​dcorb](https://togithub.com/dcorb) made their first contribution in [https://github.com/pmndrs/zustand/pull/1847](https://togithub.com/pmndrs/zustand/pull/1847) - [@​ivoilic](https://togithub.com/ivoilic) made their first contribution in [https://github.com/pmndrs/zustand/pull/1856](https://togithub.com/pmndrs/zustand/pull/1856) - [@​Kiku-CN](https://togithub.com/Kiku-CN) made their first contribution in [https://github.com/pmndrs/zustand/pull/1889](https://togithub.com/pmndrs/zustand/pull/1889) - [@​LartyHD](https://togithub.com/LartyHD) made their first contribution in [https://github.com/pmndrs/zustand/pull/1893](https://togithub.com/pmndrs/zustand/pull/1893) - [@​ChoiHyunjin](https://togithub.com/ChoiHyunjin) made their first contribution in [https://github.com/pmndrs/zustand/pull/1903](https://togithub.com/pmndrs/zustand/pull/1903) - [@​thesuryavivek](https://togithub.com/thesuryavivek) made their first contribution in [https://github.com/pmndrs/zustand/pull/1906](https://togithub.com/pmndrs/zustand/pull/1906) - [@​thedipankarroy](https://togithub.com/thedipankarroy) made their first contribution in [https://github.com/pmndrs/zustand/pull/1913](https://togithub.com/pmndrs/zustand/pull/1913) **Full Changelog**: pmndrs/zustand@v4.3.8...v4.3.9 ### [`v4.3.8`](https://togithub.com/pmndrs/zustand/releases/tag/v4.3.8) [Compare Source](https://togithub.com/pmndrs/zustand/compare/v4.3.7...v4.3.8) For persist middleware, a new option for createJSONStorage in introduced to support more cases. Note that createJSONStorage isn't a required function (and it's not very recommended as it's not type safe), and one should create a custom storage for more use cases. #### What's Changed - chore: add extension in imports by [@​dai-shi](https://togithub.com/dai-shi) in [https://github.com/pmndrs/zustand/pull/1678](https://togithub.com/pmndrs/zustand/pull/1678) - feat(middleware/persist): improve createJSONStorage for Maps by [@​lauhon](https://togithub.com/lauhon) in [https://github.com/pmndrs/zustand/pull/1763](https://togithub.com/pmndrs/zustand/pull/1763) - chore(tests): migrate to vitest by [@​arjunvegda](https://togithub.com/arjunvegda) in [https://github.com/pmndrs/zustand/pull/1753](https://togithub.com/pmndrs/zustand/pull/1753) #### New Contributors - [@​JacobWeisenburger](https://togithub.com/JacobWeisenburger) made their first contribution in [https://github.com/pmndrs/zustand/pull/1737](https://togithub.com/pmndrs/zustand/pull/1737) - [@​spacemeowx2](https://togithub.com/spacemeowx2) made their first contribution in [https://github.com/pmndrs/zustand/pull/1742](https://togithub.com/pmndrs/zustand/pull/1742) - [@​arjunvegda](https://togithub.com/arjunvegda) made their first contribution in [https://github.com/pmndrs/zustand/pull/1754](https://togithub.com/pmndrs/zustand/pull/1754) - [@​zc627788](https://togithub.com/zc627788) made their first contribution in [https://github.com/pmndrs/zustand/pull/1752](https://togithub.com/pmndrs/zustand/pull/1752) - [@​arvinxx](https://togithub.com/arvinxx) made their first contribution in [https://github.com/pmndrs/zustand/pull/1758](https://togithub.com/pmndrs/zustand/pull/1758) - [@​SilentFlute](https://togithub.com/SilentFlute) made their first contribution in [https://github.com/pmndrs/zustand/pull/1762](https://togithub.com/pmndrs/zustand/pull/1762) - [@​dannobytes](https://togithub.com/dannobytes) made their first contribution in [https://github.com/pmndrs/zustand/pull/1779](https://togithub.com/pmndrs/zustand/pull/1779) - [@​BLooDBRothER](https://togithub.com/BLooDBRothER) made their first contribution in [https://github.com/pmndrs/zustand/pull/1777](https://togithub.com/pmndrs/zustand/pull/1777) - [@​lauhon](https://togithub.com/lauhon) made their first contribution in [https://github.com/pmndrs/zustand/pull/1763](https://togithub.com/pmndrs/zustand/pull/1763) **Full Changelog**: pmndrs/zustand@v4.3.7...v4.3.8 ### [`v4.3.7`](https://togithub.com/pmndrs/zustand/releases/tag/v4.3.7) [Compare Source](https://togithub.com/pmndrs/zustand/compare/v4.3.6...v4.3.7) This includes a couple of improvements in `persist` middleware. #### What's Changed - feat(middleware/persist): add skip hydration option [#​405](https://togithub.com/pmndrs/zustand/issues/405) by [@​gmanninglive](https://togithub.com/gmanninglive) in [https://github.com/pmndrs/zustand/pull/1647](https://togithub.com/pmndrs/zustand/pull/1647) - fix(middleware/persist): ensure `persist` does not drop updates in `onRehydrateStorage` when using a synchronous storage API by [@​coffeebeats](https://togithub.com/coffeebeats) in [https://github.com/pmndrs/zustand/pull/1689](https://togithub.com/pmndrs/zustand/pull/1689) - fix(middleware/persist): ensure argument for `onRehydrateStorage` and `onHydrate` is defined on first hydration by [@​coffeebeats](https://togithub.com/coffeebeats) in [https://github.com/pmndrs/zustand/pull/1692](https://togithub.com/pmndrs/zustand/pull/1692) #### New Contributors - [@​hi-otto](https://togithub.com/hi-otto) made their first contribution in [https://github.com/pmndrs/zustand/pull/1687](https://togithub.com/pmndrs/zustand/pull/1687) - [@​pastelmind](https://togithub.com/pastelmind) made their first contribution in [https://github.com/pmndrs/zustand/pull/1707](https://togithub.com/pmndrs/zustand/pull/1707) - [@​gmanninglive](https://togithub.com/gmanninglive) made their first contribution in [https://github.com/pmndrs/zustand/pull/1647](https://togithub.com/pmndrs/zustand/pull/1647) - [@​coffeebeats](https://togithub.com/coffeebeats) made their first contribution in [https://github.com/pmndrs/zustand/pull/1689](https://togithub.com/pmndrs/zustand/pull/1689) **Full Changelog**: pmndrs/zustand@v4.3.6...v4.3.7 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 4pm on friday,before 9am on monday,every weekend" in timezone Europe/Paris, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/specfy/specfy). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xNTkuNyIsInVwZGF0ZWRJblZlciI6IjM1LjE1OS43IiwidGFyZ2V0QnJhbmNoIjoiY2hvcmUvcmVub3ZhdGVCYXNlQnJhbmNoIn0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Related Issues or Discussions
Fixes #618
Summary
The related Issue is closed because a workaround exists. But I would love to see that possible without a workaround needed. Thats why I did this fix.
Check List
yarn run prettier
for formatting code and docs