Unverified Commit 5d208e94 authored by Munawwar's avatar Munawwar Committed by GitHub

updated example for zustand v3.5.1 interface change (#25066)

createContext() no longer accepts initialState as parameter

## Documentation / Examples

- [x] Make sure the linting passes
parent b1b3b757
...@@ -10,7 +10,11 @@ const initialState = { ...@@ -10,7 +10,11 @@ const initialState = {
count: 0, 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 = {}) => { export const initializeStore = (preloadedState = {}) => {
return create((set, get) => ({ return create((set, get) => ({
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
"next": "latest", "next": "latest",
"react": "^16.9.0", "react": "^16.9.0",
"react-dom": "^16.9.0", "react-dom": "^16.9.0",
"zustand": "3.5.0" "zustand": "3.5.1"
}, },
"license": "MIT" "license": "MIT"
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment