avoiding to make custom hooks while using useShallow #2547
Unanswered
ImamJanjua
asked this question in
General
Replies: 1 comment 16 replies
-
If you don't prefer making a custom hook, how about using import { createWithEqualityFn } from 'zustand/traditional';
import { shallow } from 'zustand/shallow';
export const useDoctorStore = createWithEqualitfyFn((set) => ({
// ...
}), shallow); |
Beta Was this translation helpful? Give feedback.
16 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, am trying to create an api, like in this file I have a main function and a helper function and both functions need some data from the store to execute. And than I wanna put the main func in the useMutation hook from react query.
But the problem ofcourse is that by calling the state from the store in this way, react will complain. Solution kinda would be custom hook but that would make the structure more complicated.
I could select the the states without the useShallow hook but wouldn't i than loose the render optimization?
Beta Was this translation helpful? Give feedback.
All reactions