question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

zustand forms - steps needed to Garbage Collect zustand store

See original GitHub issue

I’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:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
TriStarGodcommented, Aug 16, 2021

@dai-shi Thanks! Zustand is amazing!

1reaction
dai-shicommented, Aug 15, 2021

yeah, something like that.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found