Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
updated example for zustand v3.5.1 interface change (vercel#25066)
Browse files Browse the repository at this point in the history
createContext() no longer accepts initialState as parameter

## Documentation / Examples

- [x] Make sure the linting passes
  • Loading branch information
Munawwar committed Jun 7, 2021
1 parent 8b0fe8d commit 80d023c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion examples/with-zustand/lib/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ const initialState = {
count: 0,
}

export const { Provider, useStore } = createContext(initialState)
const zustandContext = createContext()
export const Provider = zustandContext.Provider
// An example of how to get types
/** @type {import('zustand/index').UseStore<typeof initialState>} */
export const useStore = zustandContext.useStore

export const initializeStore = (preloadedState = {}) => {
return create((set, get) => ({
Expand Down
2 changes: 1 addition & 1 deletion examples/with-zustand/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"next": "latest",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"zustand": "3.5.0"
"zustand": "3.5.1"
},
"license": "MIT"
}

0 comments on commit 80d023c

Please sign in to comment.