import { useState } from "react"; import { FaCaretDown, FaCaretRight } from "react-icons/fa"; export const Collapsible: React.FC<{ title: string; children: () => React.ReactElement | null; }> = ({ title, children }) => { const [open, setOpen] = useState(false); const expand = (e: React.SyntheticEvent) => { e.preventDefault(); setOpen(true); }; const collapse = (e: React.SyntheticEvent) => { e.preventDefault(); setOpen(false); }; if (open) { return (
{title}
{children()}
); } else { return ( {title} ); } };