diff --git a/src/components/layout/Sidebar.tsx b/src/components/layout/Sidebar.tsx index f62392c..7373e08 100644 --- a/src/components/layout/Sidebar.tsx +++ b/src/components/layout/Sidebar.tsx @@ -1,6 +1,6 @@ 'use client'; -import { useState, useRef, useCallback, useEffect } from 'react'; +import { useState, useRef, useCallback, useEffect, useMemo } from 'react'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; // π¨ μ΄λ―Έμ§ μ΅μ νλ₯Ό μν΄ next/image μ¬μ© @@ -79,6 +79,12 @@ function CategoryItem({ category, depth, pathname, isEditMode, onDrop, onAdd, on } }; + // π νμ μΉ΄ν κ³ λ¦¬λ ID μμΌλ‘ μ λ ¬ + const sortedChildren = useMemo(() => { + if (!category.children) return []; + return [...category.children].sort((a, b) => a.id - b.id); + }, [category.children]); + return (