import { useState, useCallback, memo } from "react"; import { Transition } from "@headlessui/react"; import { MagnifyingGlassMinusIcon, MagnifyingGlassPlusIcon, ArrowTopRightOnSquareIcon, } from "@heroicons/react/24/outline"; import { FileLite } from "../types/file"; type FileProps = { file: FileLite; showScore?: boolean; }; function File(props: FileProps) { const [expanded, setExpanded] = useState(false); const handleExpand = useCallback(() => { setExpanded((prev) => !prev); }, []); return (
{props.file.name}
{props.showScore && props.file.score && (
{props.file.score.toFixed(2)}
)}
{expanded ? ( ) : ( )}
e.stopPropagation()} // prevent the click event from bubbling up to the list item >
); } export default memo(File);