Skip to main content
Glama
useGetElementOrWindow.ts430 B
'use client'; import { useEffect, useState } from 'react'; export const useGetElementOrWindow = (container?: HTMLElement) => { const [containerElement, setContainerElement] = useState< HTMLElement | undefined >(container); // This useEffect avoids the error of not finding the container useEffect(() => { setContainerElement(container ?? window.document.body); }, [container]); return containerElement; };

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/aymericzip/intlayer'

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