Skip to content

Commit 756911e

Browse files
committed
Some changes and moved the store to lib
1 parent aae2547 commit 756911e

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed
File renamed without changes.

examples/with-zustand/lib/zustandProvider.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ import { createContext, useContext } from 'react'
22

33
export const StoreContext = createContext(null)
44

5-
export const Provider = ({ children, store }) => {
5+
export const StoreProvider = ({ children, store }) => {
66
return <StoreContext.Provider value={store}>{children}</StoreContext.Provider>
77
}
88

99
export const useStore = (selector, eqFn) => {
10-
const value = useContext(StoreContext)
11-
12-
const values = value(selector, eqFn)
10+
const store = useContext(StoreContext)
11+
const values = store(selector, eqFn)
1312

1413
return values
1514
}

examples/with-zustand/pages/_app.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { Provider } from '../lib/zustandProvider'
2-
import { useHydrate } from '../store'
1+
import { StoreProvider } from '../lib/zustandProvider'
2+
import { useHydrate } from '../lib/store'
33

44
export default function App({ Component, pageProps }) {
55
const store = useHydrate(pageProps.initialZustandState)
66

77
return (
8-
<Provider store={store}>
8+
<StoreProvider store={store}>
99
<Component {...pageProps} />
10-
</Provider>
10+
</StoreProvider>
1111
)
1212
}

0 commit comments

Comments
 (0)