front-end/src/store/hooks.ts
2022-09-28 17:28:06 +03:00

11 lines
539 B
TypeScript
Executable File

import { TypedUseSelectorHook, useDispatch, useSelector } from "react-redux";
import type { RootState, AppDispatch } from "./store";
// Use throughout your app instead of plain `useDispatch` and `useSelector`
export const useAppDispatch = () => useDispatch<AppDispatch>();
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
export const dispatchStatus =
(action: string, status: ".success" | ".failure", payload: any) =>
(dispatch: any) =>
dispatch({ type: action + status, payload: payload });