How to use devtools
middleware with typescript
#976
-
Hey I wanted to try out devtools middleware but I got some TS errors. type UseStoreState = typeof initializeStore extends (...args: never) => UseBoundStore<infer T> ? T : never
///
const zustandContext = createContext<UseStoreState>()
export const ZustandProvider = zustandContext.Provider
export const useStore = zustandContext.useStore
export const initializeStore = (preloadedState = {}) => {
return create<InitialState>(
// Error here
devtools(
combine({ ...initialState, ...preloadedState }, (set, get) => ({
// ...
reset: () => {
set(emptyState)
},
}))
)
)
} Does someone can help me ? |
Beta Was this translation helpful? Give feedback.
Answered by
dai-shi
May 30, 2022
Replies: 1 comment 2 replies
-
Please take a look at the working examples with types in |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
MatteoGauthier
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please take a look at the working examples with types in
tests/middlewareTypes.test.tsx
.Also, note that since v4 we have another pattern for React Context without
zustand/context
.