.<func> is not a function from Zustand State Map #2214
Answered
by
dbritto-dev
xgenem
asked this question in
Bug report
-
// store
import { create } from 'zustand'
import {devtools, persist} from 'zustand/middleware'
interface AuthStore {
tags: Map<string, string | boolean | number>
}
const useAuthStore = create<
AuthStore,
[['zustand/devtools', never], ['zustand/persist', unknown]]
>(() => ({
tags: new Map([
['ONBOARDED', false]
]),
...
})) And accessing it in a component const tags = useAuthStore(state => state.tags)
const isOnboarded = useMemo(() => tags.get('ONBOARDED'), [tags]) Lint does not throw error at this point. But opening the app in the simulator crashes it.
|
Beta Was this translation helpful? Give feedback.
Answered by
dbritto-dev
Nov 25, 2023
Replies: 1 comment
-
@xgenem in order to support Map/Set with persist middleware you should use a custom storage: https://docs.pmnd.rs/zustand/integrations/persisting-store-data#how-do-i-use-it-with-map-and-set |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
dbritto-dev
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@xgenem in order to support Map/Set with persist middleware you should use a custom storage: https://docs.pmnd.rs/zustand/integrations/persisting-store-data#how-do-i-use-it-with-map-and-set