Skip to content
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

(middlware/persist): Limitations are not documented #1210

Closed
C-Otto opened this issue Aug 22, 2022 · 4 comments · Fixed by #1463
Closed

(middlware/persist): Limitations are not documented #1210

C-Otto opened this issue Aug 22, 2022 · 4 comments · Fixed by #1463
Labels
middleware/persist This issue is about the persist middleware

Comments

@C-Otto
Copy link

C-Otto commented Aug 22, 2022

Based on #618 and #652 there are limitations to what can be stored. Aside from the actual reasons for this limitation, users should be made aware of this. If this can be done using the typesystem for TypeScript users, that'd be great (I'm used to Java). If not, please add a big fat warning so that users don't run into issues. Without proper documentation, there's no way to know if the code you're going to write is going to work. Trial-and-error isn't a viably alternative for me, YMMV.

From #618:

By default, persist serializes the state using JSON.stringify.
Unfortunately JSON doesn't fit very well with Sets and Maps.

To me that sounds like a bug, not a documentation issue. If JSON doesn't do what you need it to do, don't use JSON (or fix it).

@dai-shi dai-shi added the middleware/persist This issue is about the persist middleware label Aug 22, 2022
@dai-shi dai-shi changed the title Limitations are not documented (middlware/persist): Limitations are not documented Aug 23, 2022
@dai-shi
Copy link
Member

dai-shi commented Dec 5, 2022

With #1463, we will be able to customize storage to support Maps and Sets.

If anyone has ideas for more improvements, please feel free to open PRs.

@C-Otto
Copy link
Author

C-Otto commented Dec 5, 2022

Until #1463 is done, please document this behaviour so that users are not surprised. To me, using sets and maps isn't any different from using other data structures (and primitives). This doesn't match zustand's expectation/offering, causing frustration.

@dai-shi
Copy link
Member

dai-shi commented Dec 5, 2022

If you have suggestion how to document it, can you please open a PR? The doc is at: https://github.com/pmndrs/zustand/blob/main/docs/integrations/persisting-store-data.md

If you are interested in using maps and sets, please help us by trying #1463 and suggesting how to document it.

@C-Otto
Copy link
Author

C-Otto commented Dec 5, 2022

I stopped using JS/TS for my projects. Others might be interested in this, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
middleware/persist This issue is about the persist middleware
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants