Skip to content

Commit

Permalink
Merge branch 'main' into fix/deprecation-warning
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi committed Aug 6, 2023
2 parents ff33e84 + 19d3df2 commit 439a73b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/previous-versions/zustand-v3-create-context.md
Expand Up @@ -117,15 +117,15 @@ Here's the diff showing how to migrate from v3 createContext to v4 API.
+ import { createStore, useStore } from "zustand";

- const useStore = create((set) => ({
+ const store = createStore((set) => ({
+ const store = createStore((set) => ({
bears: 0,
increasePopulation: () => set((state) => ({ bears: state.bears + 1 })),
removeAllBears: () => set({ bears: 0 })
}));

+ const MyContext = createContext()

+ export const Provider = ({ children }) = <MyContext.Provider value={store}>{children}</MyContext.Provider>;
+ export const Provider = ({ children }) => <MyContext.Provider value={store}>{children}</MyContext.Provider>;

+ export const useMyStore = (selector) => useStore(useContext(MyContext), selector);
```

0 comments on commit 439a73b

Please sign in to comment.