ahooks
- Version 3.8.1
- Published
- 588 kB
- 9 dependencies
- MIT license
Install
npm i ahooks
yarn add ahooks
pnpm add ahooks
Overview
react hooks library
Index
Variables
Functions
- clearCache()
- configResponsive()
- createUpdateEffect()
- useAntdTable()
- useAsyncEffect()
- useBoolean()
- useClickAway()
- useControllableValue()
- useCookieState()
- useCountDown()
- useCounter()
- useCreation()
- useDebounce()
- useDebounceEffect()
- useDebounceFn()
- useDocumentVisibility()
- useDrag()
- useDrop()
- useDynamicList()
- useEventEmitter()
- useEventListener()
- useEventTarget()
- useExternal()
- useFavicon()
- useFocusWithin()
- useFullscreen()
- useFusionTable()
- useGetState()
- useHistoryTravel()
- useHover()
- useInfiniteScroll()
- useInterval()
- useInViewport()
- useKeyPress()
- useLatest()
- useLocalStorageState()
- useLockFn()
- useLongPress()
- useMap()
- useMemoizedFn()
- useMount()
- useMouse()
- useMutationObserver()
- useNetwork()
- usePagination()
- usePrevious()
- useRafInterval()
- useRafState()
- useRafTimeout()
- useReactive()
- useRequest()
- useResetState()
- useResponsive()
- useSafeState()
- useScroll()
- useSelections()
- useSessionStorageState()
- useSet()
- useSetState()
- useSize()
- useTextSelection()
- useThrottle()
- useThrottleEffect()
- useThrottleFn()
- useTimeout()
- useTitle()
- useToggle()
- useTrackedEffect()
- useUnmount()
- useUnmountedRef()
- useUpdate()
- useVirtualList()
- useWebSocket()
- useWhyDidYouUpdate()
Variables
variable useDeepCompareEffect
const useDeepCompareEffect: any;
variable useDeepCompareLayoutEffect
const useDeepCompareLayoutEffect: any;
variable useIsomorphicLayoutEffect
const useIsomorphicLayoutEffect: any;
variable useUpdateEffect
const useUpdateEffect: any;
variable useUpdateLayoutEffect
const useUpdateLayoutEffect: any;
Functions
function clearCache
clearCache: (key?: string | string[]) => void;
function configResponsive
configResponsive: (config: ResponsiveConfig) => void;
function createUpdateEffect
createUpdateEffect: (hook: EffectHookType) => EffectHookType;
function useAntdTable
useAntdTable: <TData extends Data, TParams extends Params>( service: Service<TData, TParams>, options?: AntdTableOptions<TData, TParams>) => AntdTableResult<TData, TParams>;
function useAsyncEffect
useAsyncEffect: ( effect: () => AsyncGenerator<void, void, void> | Promise<void>, deps?: DependencyList) => void;
function useBoolean
useBoolean: (defaultValue?: boolean) => [boolean, Actions];
function useClickAway
useClickAway: <T extends Event = Event>( onClickAway: (event: T) => void, target: BasicTarget | BasicTarget[], eventName?: DocumentEventKey | DocumentEventKey[]) => void;
function useControllableValue
useControllableValue: { <T = any>(props: StandardProps<T>): [T, (v: SetStateAction<T>) => void]; <T = any>(props?: Props, options?: Options<T>): [ T, (v: SetStateAction<T>, ...args: any[]) => void ];};
function useCookieState
useCookieState: ( cookieKey: string, options?: Options) => readonly [ string, ( newValue: string | ((prevState: State) => State), newOptions?: Cookies.CookieAttributes ) => void];
function useCountDown
useCountDown: (options?: Options) => readonly [number, FormattedRes];
function useCounter
useCounter: ( initialValue?: number, options?: Options) => readonly [ number, { readonly inc: (delta?: number) => void; readonly dec: (delta?: number) => void; readonly set: (value: ValueParam) => void; readonly reset: () => void; }];
function useCreation
useCreation: <T>(factory: () => T, deps: DependencyList) => T;
function useDebounce
useDebounce: <T>(value: T, options?: DebounceOptions) => T;
function useDebounceEffect
useDebounceEffect: ( effect: EffectCallback, deps?: DependencyList, options?: DebounceOptions) => void;
function useDebounceFn
useDebounceFn: <T extends noop>( fn: T, options?: DebounceOptions) => { run: any; cancel: () => void; flush: () => ReturnType<T> | undefined };
function useDocumentVisibility
useDocumentVisibility: () => VisibilityState;
function useDrag
useDrag: <T>(data: T, target: BasicTarget, options?: Options) => void;
function useDrop
useDrop: (target: BasicTarget, options?: Options) => void;
function useDynamicList
useDynamicList: <T>(initialList?: T[]) => { list: T[]; insert: (index: number, item: T) => void; merge: (index: number, items: T[]) => void; replace: (index: number, item: T) => void; remove: (index: number) => void; batchRemove: (indexes: number[]) => void; getKey: (index: number) => number; getIndex: (key: number) => number; move: (oldIndex: number, newIndex: number) => void; push: (item: T) => void; pop: () => void; unshift: (item: T) => void; shift: () => void; sortList: (result: T[]) => T[]; resetList: (newList: T[]) => void;};
function useEventEmitter
useEventEmitter: <T = void>() => EventEmitter<T>;
function useEventListener
useEventListener: { <K extends keyof HTMLElementEventMap>( eventName: K, handler: (ev: HTMLElementEventMap[K]) => void, options?: Options<HTMLElement> ): void; <K extends keyof ElementEventMap>( eventName: K, handler: (ev: ElementEventMap[K]) => void, options?: Options<Element> ): void; <K extends keyof DocumentEventMap>( eventName: K, handler: (ev: DocumentEventMap[K]) => void, options?: Options<Document> ): void; <K extends keyof WindowEventMap>( eventName: K, handler: (ev: WindowEventMap[K]) => void, options?: Options<Window> ): void; ( eventName: string, handler: (event: Event) => void, options?: Options<Window> ): void; (eventName: string, handler: noop, options: Options<any>): void;};
function useEventTarget
useEventTarget: <T, U = T>( options?: Options<T, U>) => readonly [ T, { readonly onChange: (e: EventTarget<U>) => void; readonly reset: () => void }];
function useExternal
useExternal: (path?: string, options?: Options) => Status;
function useFavicon
useFavicon: (href: string) => void;
function useFocusWithin
useFocusWithin: (target: BasicTarget, options?: Options) => boolean;
function useFullscreen
useFullscreen: ( target: BasicTarget, options?: Options) => readonly [ boolean, { readonly enterFullscreen: () => void; readonly exitFullscreen: () => void; readonly toggleFullscreen: () => void; readonly isEnabled: true; }];
function useFusionTable
useFusionTable: <TData extends Data, TParams extends Params>( service: Service<TData, TParams>, options?: FusionTableOptions<TData, TParams>) => FusionTableResult<TData, TParams>;
function useGetState
useGetState: { <S>(initialState: S | (() => S)): [ S, Dispatch<SetStateAction<S>>, GetStateAction<S> ]; <S = undefined>(): [S, Dispatch<SetStateAction<S>>, GetStateAction<S>];};
function useHistoryTravel
useHistoryTravel: <T>( initialValue?: T, maxLength?: number) => { value: T | undefined; backLength: number; forwardLength: number; setValue: (val: T) => void; go: (step: number) => void; back: () => void; forward: () => void; reset: (...params: any[]) => void;};
function useHover
useHover: (target: BasicTarget, options?: Options) => boolean;
function useInfiniteScroll
useInfiniteScroll: <TData extends Data>( service: Service<TData>, options?: InfiniteScrollOptions<TData>) => { data: TData; loading: boolean; error: Error | undefined; loadingMore: boolean; noMore: boolean; loadMore: () => void; loadMoreAsync: () => Promise<TData>; reload: () => void; reloadAsync: () => Promise<TData>; mutate: any; cancel: () => void;};
function useInterval
useInterval: ( fn: () => void, delay?: number, options?: { immediate?: boolean }) => () => void;
function useInViewport
useInViewport: ( target: BasicTarget | BasicTarget[], options?: Options) => readonly [boolean | undefined, number | undefined];
function useKeyPress
useKeyPress: ( keyFilter: KeyFilter, eventHandler: (event: KeyboardEvent, key: KeyType) => void, option?: Options) => void;
function useLatest
useLatest: <T>(value: T) => any;
function useLocalStorageState
useLocalStorageState: <T>( key: string, options?: Options<T>) => readonly [T, (value?: SetState<T>) => void];
function useLockFn
useLockFn: <P extends any[] = any[], V = any>( fn: (...args: P) => Promise<V>) => (...args: P) => Promise<V | undefined>;
function useLongPress
useLongPress: ( onLongPress: (event: EventType) => void, target: BasicTarget, { delay, moveThreshold, onClick, onLongPressEnd }?: Options) => void;
function useMap
useMap: <K, T>( initialValue?: Iterable<readonly [K, T]>) => readonly [ Map<K, T>, { readonly set: (key: K, entry: T) => void; readonly setAll: (newMap: Iterable<readonly [K, T]>) => void; readonly remove: (key: K) => void; readonly reset: () => void; readonly get: (key: K) => T | undefined; }];
function useMemoizedFn
useMemoizedFn: <T extends noop>(fn: T) => T;
function useMount
useMount: (fn: () => void) => void;
function useMouse
useMouse: (target?: BasicTarget) => CursorState;
function useMutationObserver
useMutationObserver: ( callback: MutationCallback, target: BasicTarget, options?: MutationObserverInit) => void;
function useNetwork
useNetwork: () => NetworkState;
function usePagination
usePagination: <TData extends Data, TParams extends Params>( service: Service<TData, TParams>, options?: PaginationOptions<TData, TParams>) => PaginationResult<TData, TParams>;
function usePrevious
usePrevious: <T>(state: T, shouldUpdate?: ShouldUpdateFunc<T>) => T | undefined;
function useRafInterval
useRafInterval: ( fn: () => void, delay: number | undefined, options?: { immediate?: boolean }) => () => void;
function useRafState
useRafState: { <S>(initialState: S | (() => S)): [S, Dispatch<SetStateAction<S>>]; <S = undefined>(): [S, Dispatch<SetStateAction<S>>];};
function useRafTimeout
useRafTimeout: (fn: () => void, delay: number | undefined) => () => void;
function useReactive
useReactive: <S extends Record<string, any>>(initialState: S) => S;
function useRequest
useRequest: <TData, TParams extends any[]>( service: Service<TData, TParams>, options?: Options<TData, TParams>, plugins?: Plugin<TData, TParams>[]) => import('./types').Result<TData, TParams>;
function useResetState
useResetState: <S>( initialState: S | (() => S)) => [S, Dispatch<SetStateAction<S>>, ResetState];
function useResponsive
useResponsive: () => ResponsiveInfo;
function useSafeState
useSafeState: { <S>(initialState: S | (() => S)): [S, Dispatch<SetStateAction<S>>]; <S = undefined>(): [S, Dispatch<SetStateAction<S>>];};
function useScroll
useScroll: ( target?: Target, shouldUpdate?: ScrollListenController) => Position | undefined;
function useSelections
useSelections: <T>( items: T[], options?: T[] | Options<T>) => { readonly selected: T[]; readonly noneSelected: boolean; readonly allSelected: boolean; readonly partiallySelected: boolean; readonly setSelected: any; readonly isSelected: (item: T) => boolean; readonly select: (item: T) => void; readonly unSelect: (item: T) => void; readonly toggle: (item: T) => void; readonly selectAll: () => void; readonly unSelectAll: () => void; readonly clearAll: () => void; readonly toggleAll: () => void;};
function useSessionStorageState
useSessionStorageState: <T>( key: string, options?: Options<T>) => readonly [T, (value?: SetState<T>) => void];
function useSet
useSet: <K>( initialValue?: Iterable<K>) => readonly [ Set<K>, { readonly add: (key: K) => void; readonly remove: (key: K) => void; readonly reset: () => void; }];
function useSetState
useSetState: <S extends Record<string, any>>( initialState: S | (() => S)) => [S, SetState<S>];
function useSize
useSize: (target: BasicTarget) => Size | undefined;
function useTextSelection
useTextSelection: (target?: BasicTarget<Document | Element>) => State;
function useThrottle
useThrottle: <T>(value: T, options?: ThrottleOptions) => T;
function useThrottleEffect
useThrottleEffect: ( effect: EffectCallback, deps?: DependencyList, options?: ThrottleOptions) => void;
function useThrottleFn
useThrottleFn: <T extends noop>( fn: T, options?: ThrottleOptions) => { run: any; cancel: () => void; flush: () => ReturnType<T> | undefined };
function useTimeout
useTimeout: (fn: () => void, delay?: number) => () => void;
function useTitle
useTitle: (title: string, options?: Options) => void;
function useToggle
useToggle: { <T = boolean>(): [boolean, Actions<T>]; <T>(defaultValue: T): [T, Actions<T>]; <T, U>(defaultValue: T, reverseValue: U): [T | U, Actions<T | U>];};
function useTrackedEffect
useTrackedEffect: <T extends DependencyList>( effect: Effect<T>, deps?: [...T]) => void;
function useUnmount
useUnmount: (fn: () => void) => void;
function useUnmountedRef
useUnmountedRef: () => any;
function useUpdate
useUpdate: () => () => void;
function useVirtualList
useVirtualList: <T = any>( list: T[], options: Options<T>) => readonly [{ index: number; data: T }[], (index: number) => void];
function useWebSocket
useWebSocket: (socketUrl: string, options?: Options) => Result;
function useWhyDidYouUpdate
useWhyDidYouUpdate: (componentName: string, props: IProps) => void;
Package Files (79)
- lib/createUpdateEffect/index.d.ts
- lib/index.d.ts
- lib/useAntdTable/index.d.ts
- lib/useAsyncEffect/index.d.ts
- lib/useBoolean/index.d.ts
- lib/useClickAway/index.d.ts
- lib/useControllableValue/index.d.ts
- lib/useCookieState/index.d.ts
- lib/useCountDown/index.d.ts
- lib/useCounter/index.d.ts
- lib/useCreation/index.d.ts
- lib/useDebounce/index.d.ts
- lib/useDebounceEffect/index.d.ts
- lib/useDebounceFn/index.d.ts
- lib/useDeepCompareEffect/index.d.ts
- lib/useDeepCompareLayoutEffect/index.d.ts
- lib/useDocumentVisibility/index.d.ts
- lib/useDrag/index.d.ts
- lib/useDrop/index.d.ts
- lib/useDynamicList/index.d.ts
- lib/useEventEmitter/index.d.ts
- lib/useEventListener/index.d.ts
- lib/useEventTarget/index.d.ts
- lib/useExternal/index.d.ts
- lib/useFavicon/index.d.ts
- lib/useFocusWithin/index.d.ts
- lib/useFullscreen/index.d.ts
- lib/useFusionTable/index.d.ts
- lib/useGetState/index.d.ts
- lib/useHistoryTravel/index.d.ts
- lib/useHover/index.d.ts
- lib/useInViewport/index.d.ts
- lib/useInfiniteScroll/index.d.ts
- lib/useInterval/index.d.ts
- lib/useIsomorphicLayoutEffect/index.d.ts
- lib/useKeyPress/index.d.ts
- lib/useLatest/index.d.ts
- lib/useLocalStorageState/index.d.ts
- lib/useLockFn/index.d.ts
- lib/useLongPress/index.d.ts
- lib/useMap/index.d.ts
- lib/useMemoizedFn/index.d.ts
- lib/useMount/index.d.ts
- lib/useMouse/index.d.ts
- lib/useMutationObserver/index.d.ts
- lib/useNetwork/index.d.ts
- lib/usePagination/index.d.ts
- lib/usePrevious/index.d.ts
- lib/useRafInterval/index.d.ts
- lib/useRafState/index.d.ts
- lib/useRafTimeout/index.d.ts
- lib/useReactive/index.d.ts
- lib/useRequest/src/useRequest.d.ts
- lib/useRequest/src/utils/cache.d.ts
- lib/useResetState/index.d.ts
- lib/useResponsive/index.d.ts
- lib/useSafeState/index.d.ts
- lib/useScroll/index.d.ts
- lib/useSelections/index.d.ts
- lib/useSessionStorageState/index.d.ts
- lib/useSet/index.d.ts
- lib/useSetState/index.d.ts
- lib/useSize/index.d.ts
- lib/useTextSelection/index.d.ts
- lib/useThrottle/index.d.ts
- lib/useThrottleEffect/index.d.ts
- lib/useThrottleFn/index.d.ts
- lib/useTimeout/index.d.ts
- lib/useTitle/index.d.ts
- lib/useToggle/index.d.ts
- lib/useTrackedEffect/index.d.ts
- lib/useUnmount/index.d.ts
- lib/useUnmountedRef/index.d.ts
- lib/useUpdate/index.d.ts
- lib/useUpdateEffect/index.d.ts
- lib/useUpdateLayoutEffect/index.d.ts
- lib/useVirtualList/index.d.ts
- lib/useWebSocket/index.d.ts
- lib/useWhyDidYouUpdate/index.d.ts
Dependencies (9)
Dev Dependencies (9)
Peer Dependencies (1)
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/ahooks
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/ahooks)
- HTML<a href="https://www.jsdocs.io/package/ahooks"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 5985 ms. - Missing or incorrect documentation? Open an issue for this package.