-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
Ej/fix persisted store #746
Conversation
…hat's being saved (JSON or string)
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.
based on the typescript typings, it looks like get item has to return a string, and I assume createJSONStorage
then just turns it back to an object...its seems like it is working.
playing around with it, I also realize that getItem
, setItem
, and removeItem
don't need jsdoc typings, those are encapasulated it typing of the 'storage'
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.
Can you get rid of the unnecessary typing before you merge please and thank you
src/renderer/hooks/store.js
Outdated
if (typeof state === 'string') { | ||
store.set(key, JSON.parse(state)) | ||
} else { | ||
store.set(key, state) | ||
} |
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.
with some more testing, it seems like zustand will automatically create your object into a string (so you don't need to do this typecheck)
You can just get rid of the typings for |
Quick fix, reinstates async await syntax when getting an item from the store.
I've also made the config store consistent since zustand was stringifying the store upon save wheras by default the lib stores it as json which was resulting in configs that look like this: