import { Dropdown as BootstrapDropdown } from "bootstrap"; import { ComponentChildren } from "preact"; import { useEffect, useRef } from "preact/hooks"; interface DropdownProps { className?: string; isStatic?: boolean; children: ComponentChildren; } export default function Dropdown({ className, isStatic, children }: DropdownProps) { const dropdownRef = useRef(null); const triggerRef = useRef(null); useEffect(() => { if (!triggerRef.current) return; const dropdown = BootstrapDropdown.getOrCreateInstance(triggerRef.current); return () => dropdown.dispose(); }, []); // Add dependency array useEffect(() => { if (!dropdownRef.current) return; const handleHide = () => { // Remove console.log from production code }; const $dropdown = $(dropdownRef.current); $dropdown.on("hide.bs.dropdown", handleHide); // Add proper cleanup return () => { $dropdown.off("hide.bs.dropdown", handleHide); }; }, []); // Add dependency array return ( ) }