common-hook
Version:
提供项目中常用的 React Hooks
47 lines (46 loc) • 1.92 kB
TypeScript
export * from "./useAsyncEffect";
export * from "./useDebounceEffect";
export * from "./useDebounceFn";
export * from "./useDeepCompareEffect";
export * from "./useInterval";
export * from "./useLockFn";
export * from "./useThrottleEffect";
export * from "./useThrottleFn";
export * from "./useTimeout";
export * from "./useUpdateEffect";
/**
* @name Effect Hooks
* @example
* useUpdateEffect // 首次不执行,只在依赖项更新时执行
* useDeepCompareEffect // 依赖项更新时,深度比较
* useAsyncEffect // 支持异步函数
* useLockFn // 给一个异步函数增加竞态锁,防止并发执行
* useDebounceEffect // useEffect+防抖
* useDebounceFn // 处理防抖函数的Hook
* useThrottleEffect // useEffect+节流
* useThrottleFn // 处理函数节流的Hook
* useInterval // 处理setInterval的Hook
* useTimeout // 处理setTimeout的Hook
*/
export declare const Effect: {
useAsyncEffect: (effect: () => AsyncGenerator<void, void, void> | Promise<void>, deps?: any) => void;
useDebounceEffect: (effect: any, deps?: any, options?: any) => void;
useDebounceFn: <T extends (...args: any) => any>(fn: T, options?: any) => {
run: any;
cancel: any;
flush: any;
};
useDeepCompareEffect: (effect: any, dependencies: any) => void;
useInterval: (fn: () => void, delay: number | undefined, options?: {
immediate?: boolean;
}) => any;
useLockFn: <P extends any[] = any[], V extends unknown = any>(fn: (...args: P) => Promise<V>) => any;
useThrottleEffect: (effect: any, deps?: any, options?: any) => void;
useThrottleFn: <T extends (...args: any) => any>(fn: T, options?: any) => {
run: any;
cancel: any;
flush: any;
};
useTimeout: (fn: () => void, delay: number | undefined) => any;
useUpdateEffect: any;
};