feat(blog): close #45

This commit is contained in:
Kim, Jimin 2023-06-26 22:45:04 +09:00
parent 76d4c680d2
commit cda0e813ec
2 changed files with 4 additions and 2 deletions

View file

@ -99,7 +99,7 @@ const Sidebar = () => {
{/* sidebar items */} {/* sidebar items */}
{NavbarData.map((item, index) => { {NavbarData.map((item, index) => {
return <SubMenu item={item} key={index} /> return <SubMenu onClick={toggleSidebar} item={item} key={index} />
})} })}
</SidebarWrap> </SidebarWrap>
</SidebarNav> </SidebarNav>

View file

@ -45,12 +45,14 @@ const SidebarLabel = styled.span`
interface Props { interface Props {
item: Item item: Item
onClick: () => void
} }
const SubMenu = ({ item }: Props) => { const SubMenu = ({ item, onClick }: Props) => {
const { path, icon, title } = item const { path, icon, title } = item
const [isSubNavOpen, setSubNavOpen] = useState(false) const [isSubNavOpen, setSubNavOpen] = useState(false)
const handleSidebarLinkClick = useCallback(() => { const handleSidebarLinkClick = useCallback(() => {
onClick()
setSubNavOpen((prev) => !prev) setSubNavOpen((prev) => !prev)
}, [isSubNavOpen]) }, [isSubNavOpen])