Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/components/common/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ import {
} from 'react';
import Down from '@/assets/icons/dropdown.svg';

interface DropdownProps {
options: string[];
selected: string;
setSelect: Dispatch<SetStateAction<string>>; // Dispatch<SetStateAction<string>>๋Š” setํ•จ์ˆ˜ ํƒ€์ž…
interface DropdownProps<OptionType extends string> {
options: readonly OptionType[];
selected: OptionType;
setSelect: Dispatch<SetStateAction<OptionType>>; // Dispatch<SetStateAction<string>>๋Š” setํ•จ์ˆ˜ ํƒ€์ž…
placeholder?: string;
variant: 'form' | 'filter';
}

export default function Dropdown({
export default function Dropdown<OptionType extends string>({
options,
selected,
setSelect,
placeholder = '์„ ํƒ',
variant,
}: DropdownProps) {
}: DropdownProps<OptionType>) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๐Ÿ’ฌ generic type์ด๋ผ๋ฉด ๊ทธ๋ƒฅ OptionType ๋ง๊ณ  ๊ฐ„๋‹จํ•˜๊ฒŒ T๋ผ๊ณ  ์ ์–ด๋„ ๋˜์ง€ ์•Š๋‚˜ ์‹ถ๋„ค์š”!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„ ์›๋ž˜ T๋กœ ํ•˜๋ ค๊ณ  ํ–ˆ๋Š”๋ฐ ์ข€ ๋” ์•Œ์•„๋ณด๊ธฐ ์ข‹๊ฒŒ ์˜ต์…˜์œผ๋กœ ๋„ฃ์—ˆ์Šต๋‹ˆ๋‹ค!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ณ€๊ฒฝํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค!

const [isOpen, setIsOpen] = useState(false);
const dropdownRef = useRef<HTMLDivElement>(null);

Expand All @@ -33,7 +33,7 @@ export default function Dropdown({
setIsOpen(false);
};

const handleSelect = (options: string) => {
const handleSelect = (options: OptionType) => {
setSelect(options);
closeDropdown();
};
Expand Down