UNPKG

887 BTypeScriptView Raw
1import { EffectCallback, DependencyList, Comparator } from '../types';
2/**
3 * A replacement for React.useEffect that'll allow for custom and deep
4 * compares of the dependency list.
5 * @see {@link https://reactjs.org/docs/hooks-reference.html#useeffect}
6 * @param callback Accepts a callback that's forwarded to React.useEffect
7 * @param dependencies A dependency array similar to React.useEffect however it utilizes a deep compare
8 * @param customCompare Opportunity to provide a custom compare function
9 * @example
10 * function ComponentExample() {
11 * const [, forceUpdate] = useState();
12 * const obj = {a: 1};
13 *
14 * useDeepEffect(() => {
15 * console.log('useDeepEffect invocation');
16 * forceUpdate(obj);
17 * }, [obj]);
18 *
19 * return null;
20 * }
21 */
22export declare function useDeepEffect(callback: EffectCallback, dependencies: DependencyList, customCompare?: Comparator): void;