Skip to content

Commit

Permalink
Add currying parenthesis to create
Browse files Browse the repository at this point in the history
According to [zustand TypeScript Guide](https://docs.pmnd.rs/zustand/guides/typescript) and [zustand Github TypeScript Usage](/~https://github.com/pmndrs/zustand?tab=readme-ov-file#typescript-usage)    instead of create(...), you have to write create<T>()(...) so Typescript can infer the type of the state correctly. This is a workaround for [microsoft/TypeScript#10571](microsoft/TypeScript#10571)
  • Loading branch information
DragonSenses committed Feb 1, 2024
1 parent a1836fd commit 235c31e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hooks/useMobileSidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type MobileSidebarStore = {
onClose: () => void;
};

const useMobileSidebar = create<MobileSidebarStore>((set) => ({
const useMobileSidebar = create<MobileSidebarStore>()((set) => ({
isOpen: false,
onOpen: () => set({ isOpen: true }),
onClose: () => set({ isOpen: false }),
Expand Down

0 comments on commit 235c31e

Please sign in to comment.