Skip to content

Commit

Permalink
create zustand store
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeKarow committed Aug 25, 2023
1 parent 714194d commit 3fec980
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/ui/store/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { create } from 'zustand'

export const useStore = create<Store>((set) => ({
loading: false,
setLoading: (loading: boolean) => set(() => ({ loading })),

canSave: false,
setCanSave: (canSave: boolean) => set(() => ({ canSave })),
}))

export const useLoading = () => useStore((state) => [state.loading, state.setLoading])
export const useCanSave = () => useStore((state) => [state.canSave, state.setCanSave])

interface Store {
loading: boolean
setLoading: (loading: boolean) => void
canSave: boolean
setCanSave: (canSave: boolean) => void
}

0 comments on commit 3fec980

Please sign in to comment.