@leafygreen-ui/hooks
Version:
LeafyGreen UI Kit Custom Hooks
25 lines • 868 B
TypeScript
/**
* Based on https://github.com/fitzmode/use-dynamic-refs/blob/master/src/index.tsx
*/
import * as React from 'react';
export interface UseDynamicRefsArgs {
prefix?: string;
}
/** The Map type for a given ref object */
export type RefMap<T> = Map<string, React.RefObject<T>>;
/**
* @internal
*/
export declare function getGetRef<T>(refMap: RefMap<T>): {
(): undefined;
(key: string): React.RefObject<T>;
};
/** The function signature for the function returned by `useDynamicRefs` */
export type DynamicRefGetter<T> = ReturnType<typeof getGetRef<T>>;
/**
* Returns a ref "getter" function for the specified namespace (prefix).
*
* Calling the ref "getter" with a key will return a ref for the given namespace and key
*/
export declare function useDynamicRefs<T>(args?: UseDynamicRefsArgs): DynamicRefGetter<T>;
//# sourceMappingURL=index.d.ts.map