force-orange-2022/src/utils/useAction.ts
2022-04-18 00:21:33 +02:00

17 lines
359 B
TypeScript

import { useDispatch } from "react-redux"
import { useMemo } from "react"
const useAction = (action: (...args: any[]) => any): any => {
const dispatch = useDispatch()
return useMemo(
() =>
(...args: any[]) => {
dispatch(action(...args))
},
[dispatch, action]
)
}
export default useAction