/** * @fileoverview Combine multiple refs (callback refs and ref objects) into a * single ref callback. Required whenever a component both forwards a ref AND * needs its own internal ref to the same DOM node. * @author Saasflare™ * @module packages/ui/hooks/use-merged-ref * @package ui * * @example * const Card = forwardRef(function Card(props, forwardedRef) { * const internalRef = useRef(null); * const ref = useMergedRef(internalRef, forwardedRef); * return
; * }); */ import { type MutableRefObject, type Ref, type RefCallback } from "react"; /** Anything React accepts as a ref slot. */ export type PossibleRef = Ref | MutableRefObject | null | undefined; /** * Merges any number of refs into a single ref callback. The callback is * memoized on the identity of the input refs — if you pass new ref objects * on every render, the callback identity will change and React will * detach/reattach. In practice pass stable ref objects. * * @param refs - One or more refs (object refs or callback refs). * @returns A stable ref callback that writes the node to every input ref. * * @example * const ref = useMergedRef(forwardedRef, internalRef); *
*/ export declare function useMergedRef(...refs: PossibleRef[]): RefCallback;