Deriving computed values from a Zustand store: this is how I roll #1341
Replies: 2 comments 2 replies
-
Hey, I have similar question in #1384 and really like how you use hooks to solve this problem. After doing some research I found zustand-middleware-computed-state (see #1363), that may help you |
Beta Was this translation helpful? Give feedback.
2 replies
-
Slightly related, I just made "derive-zustand": https://twitter.com/dai_shi/status/1589279106201718785 |
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
-
I'm doing some experiments to find out the best way to apply computed values in the Zustand programming model. So far, my cleanest solution is using a custom hook to derive values from the state, as shown below (TypeScript code):
Usage example in a component:
I'm wondering: is there a better approach to this situation?
Any gotchas?
Beta Was this translation helpful? Give feedback.
All reactions