Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

docs: fix glossary filter flicker on remount with callback ref

Sushmitha Mallesh2cf760ee1747
diff --git a/docs/components/glossary.tsx b/docs/components/glossary.tsx
index a816dc2ba..084d49183 100644
--- a/docs/components/glossary.tsx
+++ b/docs/components/glossary.tsx
@@ -2,10 +2,9 @@
import {
useState,
+ useCallback,
createContext,
useContext,
- useRef,
- useEffect,
type ReactNode,
} from 'react';
import { cn } from '@/lib/utils';
@@ -73,13 +72,12 @@ export function GlossaryTerm({
children: ReactNode;
}) {
const filter = useContext(FilterContext);
- const definitionRef = useRef<HTMLDivElement>(null);
const [definitionText, setDefinitionText] = useState('');
const id = slugify(name);
- useEffect(() => {
- if (definitionRef.current) {
- setDefinitionText(definitionRef.current.textContent?.toLowerCase() || '');
+ const definitionRef = useCallback((node: HTMLDivElement | null) => {
+ if (node) {
+ setDefinitionText(node.textContent?.toLowerCase() || '');
}
}, []);