-
Notifications
You must be signed in to change notification settings - Fork 0
[REFACTOR] Accordion 컴포넌트의 defaultValue prop 지원 #85
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,6 +17,11 @@ type AccordionRootProps = { | |||||
| * The content of the Accordion, typically AccordionItem components. | ||||||
| */ | ||||||
| children: ReactNode; | ||||||
| /** | ||||||
| * The default value of the Accordion item that should be open on initial render. | ||||||
| */ | ||||||
| defaultValue?: string[]; | ||||||
|
Comment on lines
+20
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial 단일 모드에서 타입 안정성을 개선할 수 있습니다.
타입을 조건부로 정의하는 것을 고려해보세요: type AccordionRootProps = {
type?: 'single' | 'multiple';
children: ReactNode;
className?: string;
} & (
| { type?: 'single'; defaultValue?: string }
| { type?: 'multiple'; defaultValue?: string[] }
);또는 더 간단하게 유니온 타입을 사용할 수 있습니다: type AccordionRootProps = {
type?: 'single' | 'multiple';
children: ReactNode;
defaultValue?: string | string[];
className?: string;
};🤖 Prompt for AI Agents |
||||||
|
|
||||||
| /** | ||||||
| * Additional class names to apply to the AccordionRoot. | ||||||
| */ | ||||||
|
|
@@ -27,9 +32,11 @@ export function AccordionRoot({ | |||||
| type = 'single', | ||||||
| className = '', | ||||||
| children, | ||||||
| defaultValue, | ||||||
| ...props | ||||||
| }: AccordionRootProps) { | ||||||
| const [openItems, setOpenItems] = useState<string[]>([]); | ||||||
| const defaultOpenItem = defaultValue ? defaultValue : []; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial nullish coalescing 연산자로 간소화할 수 있습니다. 현재 삼항 연산자 대신 nullish coalescing 연산자( 다음 diff를 적용하세요: - const defaultOpenItem = defaultValue ? defaultValue : [];
+ const defaultOpenItem = defaultValue ?? [];📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| const [openItems, setOpenItems] = useState<string[]>(defaultOpenItem); | ||||||
|
|
||||||
| const toggleItem = (value: string) => { | ||||||
| if (type === 'single') { | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
스토리 코드는 잘 작동하지만, trigger 텍스트에 오타가 있습니다.
86번 라인에서 두 번째
AccordionItem의 trigger가 "질문 1"로 되어 있는데, "질문 2"로 수정해야 합니다. 첫 번째 아이템과 동일한 텍스트가 표시되어 혼란을 줄 수 있습니다.다음 diff를 적용하여 수정하세요:
📝 Committable suggestion
🤖 Prompt for AI Agents