UNPKG

583 BTypeScriptView Raw
1/**
2 * Returns a function that triggers a component update. the hook equivalent to
3 * `this.forceUpdate()` in a class component. In most cases using a state value directly
4 * is preferable but may be required in some advanced usages of refs for interop or
5 * when direct DOM manipulation is required.
6 *
7 * ```ts
8 * const forceUpdate = useForceUpdate();
9 *
10 * const updateOnClick = useCallback(() => {
11 * forceUpdate()
12 * }, [forceUpdate])
13 *
14 * return <button type="button" onClick={updateOnClick}>Hi there</button>
15 * ```
16 */
17export default function useForceUpdate(): () => void;