diff --git a/.gitignore b/.gitignore index 4641547..780ea47 100644 --- a/.gitignore +++ b/.gitignore @@ -52,7 +52,7 @@ dist/ downloads/ eggs/ .eggs/ -lib/ +server/lib/ lib64/ parts/ sdist/ diff --git a/app/src/lib/hooks.ts b/app/src/lib/hooks.ts new file mode 100644 index 0000000..877cfa7 --- /dev/null +++ b/app/src/lib/hooks.ts @@ -0,0 +1,18 @@ +import { + useDispatch, + useSelector, + useStore, +} from 'react-redux'; +import type { + TypedUseSelectorHook, +} from 'react-redux'; +import type { + AppDispatch, + AppStore, + RootState, +} from './store'; + +// Use throughout your app instead of plain `useDispatch` and `useSelector` +export const useAppDispatch: () => AppDispatch = useDispatch; +export const useAppSelector: TypedUseSelectorHook = useSelector; +export const useAppStore: () => AppStore = useStore; diff --git a/app/src/lib/store.ts b/app/src/lib/store.ts new file mode 100644 index 0000000..4346d87 --- /dev/null +++ b/app/src/lib/store.ts @@ -0,0 +1,14 @@ +import { + configureStore, +} from '@reduxjs/toolkit'; + +export const makeStore = () => + configureStore({ + reducer: {}, + }); + +// Infer the type of makeStore +export type AppStore = ReturnType; +// Infer the `RootState` and `AppDispatch` types from the store itself +export type RootState = ReturnType; +export type AppDispatch = AppStore['dispatch']; diff --git a/app/src/lib/utils.ts b/app/src/lib/utils.ts new file mode 100644 index 0000000..b8313a7 --- /dev/null +++ b/app/src/lib/utils.ts @@ -0,0 +1,11 @@ +import { + type ClassValue, + clsx, +} from 'clsx'; +import { + twMerge, +} from 'tailwind-merge'; + +export function cn(...inputs: ClassValue[]) { + return twMerge(clsx(inputs)); +}