Skip to content

Commit

Permalink
docs: fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
kangju2000 committed Aug 2, 2023
1 parent 2778e71 commit 1265324
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/previous-versions/zustand-v3-create-context.md
Original file line number Diff line number Diff line change
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 1265324

Please sign in to comment.