UNPKG

580 BJavaScriptView Raw
1import React from "react";
2import { useDispatch, useSelector } from "react-redux";
3export function useLoadingStatus(identifier = "global") {
4 return useSelector((state) => state.loading[identifier] > 0);
5}
6/**
7 * Action parameters must be of primitive types, so that the dependency check can work well.
8 * No need add dispatch to dep list, because it is always fixed.
9 */
10export function useModuleAction(actionCreator, ...deps) {
11 const dispatch = useDispatch();
12 return React.useCallback(() => dispatch(actionCreator(...deps)), deps);
13}
14//# sourceMappingURL=hooks.js.map
\No newline at end of file