upd
This commit is contained in:
@@ -6,24 +6,26 @@ import { useClickAway } from "@uidotdev/usehooks";
|
||||
import clsx from "clsx";
|
||||
import ChevronDownIcon from "../icons/ChevronDownIcon";
|
||||
import CheckIcon from "../icons/CheckIcon";
|
||||
|
||||
function Select({
|
||||
options,
|
||||
onSelect,
|
||||
className = "",
|
||||
label = "",
|
||||
defaultOption = "",
|
||||
}: {
|
||||
options: string[];
|
||||
onSelect: (option: string) => void;
|
||||
defaultOption: string;
|
||||
className?: string;
|
||||
label?: string;
|
||||
}) {
|
||||
const [isShow, setIsShow] = useState(false);
|
||||
const [selectedOption, setSelectedOption] = useState(options[0]);
|
||||
const [selectedOption, setSelectedOption] = useState(defaultOption);
|
||||
|
||||
const ref = useClickAway<HTMLDivElement>(() => setIsShow(false));
|
||||
|
||||
useEffect(() => {
|
||||
onSelect(selectedOption);
|
||||
}, [selectedOption]);
|
||||
useEffect(() => onSelect(selectedOption), [selectedOption]);
|
||||
|
||||
return (
|
||||
<div ref={ref} className={clsx("relative", className)}>
|
||||
|
||||
Reference in New Issue
Block a user