Destroy dynamically created stores #2254
Unanswered
KnightSlayer
asked this question in
Q&A
Replies: 2 comments 9 replies
-
|
@dai-shi |
Beta Was this translation helpful? Give feedback.
3 replies
-
|
Zustand stores are basically garbage collectable if there are no subscriptions. zustand/src/middleware/devtools.ts Line 252 in a4578fa As it doesn't hold the unsubscribe function, it's not currently possible.It would be an improvement to attach a method so that we can do useMyStore.disconnectDevtools().Anyone can try that, but it's pretty challenging. (Like, trackedConnections and TypeScript typing.)
Meanwhile, only the solution would be avoid using |
Beta Was this translation helpful? Give feedback.
6 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.
-
Hi
I'm using
subscribeWithSelectoranddevtoolsmiddlewares . Let me share some of my code. Here is my helper function for store creation:I'm dynamically creating stores. For example imagine I'm creating separate store for each row of dynamic table:
Some times (i.e. table page changed) I want to destroy some of my stores. I don't want to "clear" state. I want to completely destroy the store. So that it will be deleted even from devtools. Is it possible? Could anybody help me please?
PS
row2Store.destroy()method is deprecated and anyway it doesn't really destroy the storeBeta Was this translation helpful? Give feedback.
All reactions