Can I use wrapper function for useShallow
?
#2828
-
Can I do something like that: import { create } from 'zustand'
const useStore = create((set) => ({
count: 1,
inc: () => set((state) => ({ count: state.count + 1 })),
}))
const useStoreWithShallow = <idk what to put here>
function Counter() {
const [ count, inc ] = useStoreWithShallow((state) => [state.count, state.inc]))
return (
<div>
<span>{count}</span>
<button onClick={inc}>one up</button>
</div>
)
} |
Beta Was this translation helpful? Give feedback.
Answered by
dbritto-dev
Oct 31, 2024
Replies: 1 comment 4 replies
-
@Yoha485 here you go -> https://zustand.docs.pmnd.rs/apis/create-with-equality-fn |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
Yoha485
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Yoha485 here you go -> https://zustand.docs.pmnd.rs/apis/create-with-equality-fn