Skip to main content
Glama
useTransformRef.js•725 B
import { assignRef } from './assignRef'; import { useCallbackRef } from './useRef'; /** * Create a _lense_ on Ref, making it possible to transform ref value * @param {ReactRef} ref * @param {Function} transformer. 👉 Ref would be __NOT updated__ on `transformer` update. * @returns {RefObject} * * @see https://github.com/theKashey/use-callback-ref#usetransformref-to-replace-reactuseimperativehandle * @example * * const ResizableWithRef = forwardRef((props, ref) => * <Resizable {...props} ref={useTransformRef(ref, i => i ? i.resizable : null)}/> * ); */ export function useTransformRef(ref, transformer) { return useCallbackRef(null, function (value) { return assignRef(ref, transformer(value)); }); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kkShrihari/miEAA3_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server