UNPKG

@wix/design-system

Version:

@wix/design-system

20 lines 1.03 kB
import type { MutableRefObject } from 'react'; /** * React.Ref uses the readonly type `React.RefObject` instead of * `React.MutableRefObject`, We pretty much always assume ref objects are * mutable (at least when we create them), so this type is a workaround so some * of the weird mechanics of using refs with TS. */ export type AssignableRef<ValueType> = { bivarianceHack(instance: ValueType | null): void; }['bivarianceHack'] | MutableRefObject<ValueType | null>; export declare function assignRef<RefValueType = any>(ref: AssignableRef<RefValueType> | null | undefined, value: any): void; /** * Passes or assigns a value to multiple refs (typically a DOM node). Useful for * dealing with components that need an explicit ref for DOM calculations but * also forwards refs assigned by an app. * * @param refs Refs to fork */ export declare function mergeRefs<RefValueType = any>(...refs: (AssignableRef<RefValueType> | null | undefined)[]): ((node: any) => void) | null; //# sourceMappingURL=mergeRefs.d.ts.map