diff --git a/src/utils/useAction.ts b/src/utils/useAction.ts index 31a070d..6420f7a 100644 --- a/src/utils/useAction.ts +++ b/src/utils/useAction.ts @@ -1,11 +1,16 @@ import { useDispatch } from "react-redux" +import { useMemo } from "react" const useAction = (action: (...args: any[]) => any): any => { const dispatch = useDispatch() - return (...args: any[]) => { - dispatch(action(...args)) - } + return useMemo( + () => + (...args: any[]) => { + dispatch(action(...args)) + }, + [dispatch, action] + ) } export default useAction