import { useState } from "preact/hooks"; const Dropdown = ({ name, options }: { name: string; options: string[] }) => { const [isOpen, setIsOpen] = useState(false); const [choice, setChoice] = useState( localStorage.getItem(name) || options[0] ); return (

{name}

setIsOpen(!isOpen)} >
{choice}
{isOpen && (
{options.map((option: string) => (
{ setIsOpen(false); setChoice(option); localStorage.setItem(name, option); }} > {option}
))}
)}
); }; export default Dropdown;