Skip to content

Commit

Permalink
refactor: getChildren 함수 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
gahyuun committed Feb 18, 2024
1 parent 6cea9c5 commit 91f3565
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app/ui/view/molecule/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ type ListProps = {
children: ReactNode;
};

export function List({ children }: ListProps) {
const getChildren = (type: typeof ListHeader | typeof ListRow) => {
const childrenArray = Children.toArray(children);
return childrenArray.filter((child) => isValidElement(child) && child.type === type);
};
const getChildren = (children: ReactNode, type: typeof ListHeader | typeof ListRow) => {
const childrenArray = Children.toArray(children);
return childrenArray.filter((child) => isValidElement(child) && child.type === type);
};

export function List({ children }: ListProps) {
return (
<div className="flex flex-col gap-2.5 w-[900px]">
{getChildren(ListHeader)}
<div className="rounded-2xl border-[1px] border-[#0000004d] ">{getChildren(ListRow)}</div>
{getChildren(children, ListHeader)}
<div className="rounded-2xl border-[1px] border-[#0000004d] ">{getChildren(children, ListRow)}</div>
</div>
);
}
Expand Down

0 comments on commit 91f3565

Please sign in to comment.