Making get() work more like set() 🤔
#3189
Unanswered
mindplay-dk
asked this question in
Ideas
Replies: 3 comments 6 replies
-
|
I don't think the first two cases are too bad. |
Beta Was this translation helpful? Give feedback.
3 replies
-
|
It feels to me that the zustand way is this: const useFooStore = create((set) => ({
a: 0,
b: 0,
reset() {
set({ a: 0, b: 0 });
},
}));
const useFooProduct = () => useFooStore(({ a, b }) => a * b); |
Beta Was this translation helpful? Give feedback.
3 replies
-
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
Uh oh!
There was an error while loading. Please reload this page.
-
Just a thought but...
Calling
get()twice. I mean, no, right?So then:
Still, ugh... the ceremonious unpacking of state before you can use it... ehh.
So then how about:
Wouldn't it be kind of cool if you could pass a selector to
get()?It makes the code look more consistent, doesn't it?
I was honestly kind of surprised this doesn't exist.
Why not? 🙂
Beta Was this translation helpful? Give feedback.
All reactions