zustand forms - steps needed to Garbage Collect zustand store
See original GitHub issueI’m using zustands with a passive form generator. A summarized version looks like
const createFormStore = () => createStore(....);
function Form(initialState, onFieldAsync, onFormAsync) {
const formStoreRef = useRef(createFormStore());
...
useEffect(() => {
formStoreRef.current.setForm(initialData);
return () => {
// destroy form
};
}, [intialData]);
return (
<form ...>
<FormContext.Provider value={formStoreRef.current.formStore)>
...
</FormContext>
</form>
)
}
It works. However, I’m not sure if the older forms were Garbage Collected. Do I have to take any steps to get it Garbage Collected (ie destroy zustand store)?
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How are you setting up your Selectors while Zustand? - Reddit
I feel the docs on selector usage in Zustand is vague. The examples are very base and one-offs and they don't show how...
Read more >The new wave of React state management - Frontend Mastery
Hooking into the React lifecycle to store state means it's easier to take advantage of automatic garbage collection when the component ...
Read more >Bear necessities for state management with React Query ...
Why Zustand? Small, fast and scalable bear-bones state-management solution using simplified flux principles. Simple and un-opinionated; Makes ...
Read more >Add feature to view if it can undo or redo · Issue #15 - GitHub
I was thinking if it would be possible to add apis to check if it can undo or redo. I was thinking maybe:...
Read more >The new wave of React state management | Hacker News
If I had taken a paid course to learn a state management library I would probably advocate for it ... I switched to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@dai-shi Thanks! Zustand is amazing!
yeah, something like that.