Web Storage API & Safari #1912
Unanswered
nothingrandom
asked this question in
Bug report
Replies: 1 comment 5 replies
-
Thanks for reporting! Can you identify the problem? This is what I tried: ChromeSafari |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Using the Web Storage API for persisting storage (specifically for browser extensions), @andyhails and I discovered that there is a bug in
createJSONStorage
for Safari that causes it to stringify and persist store functions (e.g.foo()
) as objects (e.g.foo: {}
).This does not exist as an issue for Firefox, Chrome, or other Chromium browsers.
We found this bug to be extremely inconsistent between builds for Safari through xCode and throughout runtime, however, did find a fix through a custom
createJSONStorage
.Proposal
Filter functions out from being in the persisted store. Zustand handles this just fine, combining the persisted store of strings, booleans, and objects with the non-persisted store which includes those functions no longer being persisted.
createJSONStorage.ts
Beta Was this translation helpful? Give feedback.
All reactions