[Store Persist] How to create a new store with a dynamic naming mechanism without merging from the old state #2925
Unanswered
hassanedelbi
asked this question in
Q&A
Replies: 1 comment
-
@hassanedelbi would you mind creating a minimal repro on stackblitz? I'd be happy to help |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
From the docs:
setOptions
Type: (newOptions: Partial) => void
Changes the middleware options. Note that the new options will be merged with the current ones.
i am using persist like this
`
useEffect(() => {
}, [user]);
`
I am saving some preferences per user in a separate localStorage key
Expected:
for example when the user1 logs in i have user-1-preferences-storage
then when the user logs in with user 2 it s user-2-preferences-storage
Current Behavior
currently when the user logs in with user 1 i ll have user-1-preferences-storage
when i switch to user 2 and then doing .persist.setOptions it s copying the user-1 data to user-2 and reseting user-1 preferences to initial.
Beta Was this translation helpful? Give feedback.
All reactions