import { useCallback } from "react" ; import { mapValues } from "lodash" ; import { useDispatch } from "redux-react-hook" ; export function useMappedActions < T > ( actionsObj ) { const dispatch = useDispatch ( ) ; return mapValues ( actionsObj , value => { return useCallback ( ( ... args ) => dispatch ( value ( ... args ) ) , [ ] ) ; } ) ; }