@keybittech/awayto
Version:
Deploy a fully-featured application in about 10 minutes that is primed for quick development. Do business, impress a client with a quick demo, finish your poc with time to spare; all easily achievable with Awayto.
15 lines (14 loc) • 547 B
text/typescript
import { useDispatch } from './useDispatch';
import { act } from './actions';
import { ILoadedState, IActionTypes } from 'awayto';
/**
* `useAct` is a wrapper for dispatching actions. Give it an action type (i.e. SET_SNACK), a loader boolean, and the action payload if necessary.
*
* @category Hooks
*/
export function useAct(): (actionType: IActionTypes, state: ILoadedState, meta?: unknown) => void {
const dispatch = useDispatch();
return (actionType, state, meta) => {
dispatch(act(actionType, state, meta));
};
}