How do you debug code that use zustand? #2519
Answered
by
LeoRedin
fredericrous
asked this question in
Q&A
-
the technique I use is const myproperty = useStore((state) => state.myproperty); <pre style={{ width: '100%', height: '20vh', overflow: 'auto' }}>
{JSON.stringify(myproperty, null, 4)}
</pre> I tried the extensions zukeeper and zusty, however they make my code throw errors. I don't want to update my code because of an extension. example of throw: I initialize a state property, I get the property directly without getter like it's done with "bear" in the doc of zustand.. it throws that my array is undefined would you have a better technique to know what zustand state is and help with debugging? |
Beta Was this translation helpful? Give feedback.
Answered by
LeoRedin
May 2, 2024
Replies: 1 comment 3 replies
-
@fredericrous would you mind sharing us a minimal repro on stackblitz? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/pmndrs/zustand?tab=readme-ov-file#redux-devtools
The easiest way I see is using the built-in
devtools
middleware from zustand. With that you need a Redux Devtools or similar extension and you can see pretty much everything from the extension itself.Or you can use the logger recipe from zustand docs