useActions()
↔ Custom Hook to bind actionCreators to Dispatch
import { useDispatch } from "react-redux";
import { bindActionCreators } from "redux";
import { actionCreators } from "../state";
export const useActions = () => {
const dispatch = useDispatch();
return bindActionCreators(actionCreators, dispatch);
};
!refactors code by auto calling dispatch on actionCreators
no need to type dispatch(actionCreator) manually