Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

태그 버튼 색상 적용 #765

Merged
merged 10 commits into from
Oct 16, 2024
8 changes: 5 additions & 3 deletions frontend/src/components/TagButton/TagButton.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useMemo } from 'react';

import { XSignIcon } from '@/assets/images';
import { Text } from '@/components';
import { TAG_COLORS, INPUT_TAG_COLOR } from '@/style/tagColors';
Expand All @@ -14,10 +16,10 @@ interface Props {
onClick?: () => void;
}

const TagButton = ({ id, name, isFocused = false, disabled = false, variant = 'default', onClick }: Props) => {
const getTagColor = (id?: number) => (id ? TAG_COLORS[id % TAG_COLORS.length] : INPUT_TAG_COLOR);
const getTagColor = (id?: number) => (id ? TAG_COLORS[id % TAG_COLORS.length] : INPUT_TAG_COLOR);

const { background, border } = getTagColor(id);
const TagButton = ({ id, name, isFocused = false, disabled = false, variant = 'default', onClick }: Props) => {
const { background, border } = useMemo(() => getTagColor(id), [id]);
Copy link
Contributor

Choose a reason for hiding this comment

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

간단한 연산이라서 useMemo를 사용하지 않는 편이 더 좋을 것 같다는 개인적인 의견입니다..!!


return (
<S.TagButtonWrapper
Expand Down