Skip to content

Commit 3395b12

Browse files
committed
라우트 이동할 경우 토글 메뉴 닫히도록 수정
1 parent 5d3781b commit 3395b12

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

frontend/components/core/NavBar.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react'
1+
import React, { useState, useEffect } from 'react'
22
import { routes, RouteType } from '../../routes/routes'
33
import styled from 'styled-components'
44
import { useTranslation } from 'react-i18next'
@@ -7,6 +7,7 @@ import Image from 'next/image'
77
import { media } from '../../assets/styles/mixin'
88
import SnsLink from './SnsLink'
99
import PyconLogoWhite from '../../public/images/pyconkr_2022_logo_white.png'
10+
import Link from 'next/link'
1011

1112
const Container = styled.nav`
1213
display: flex;
@@ -40,7 +41,7 @@ const ListItem = styled.li<{ active?: boolean }>`
4041
color: ${(props) => props.theme.colors.white};
4142
position: relative;
4243
`
43-
export const Link = styled.a`
44+
export const BlockLink = styled(Link)`
4445
display: block;
4546
cursor: pointer;
4647
`
@@ -131,6 +132,10 @@ const NavBar = (props: NavProps) => {
131132
router.push(router.asPath, undefined, { locale: lang })
132133
}
133134

135+
useEffect(() => {
136+
setOpenedSubMenu('')
137+
}, [router.pathname])
138+
134139
return (
135140
<Container isTransparent={isHome}>
136141
<HomeLink href="/">
@@ -160,18 +165,18 @@ const NavBar = (props: NavProps) => {
160165
<SubMenuList>
161166
{route.subMenu.map((subMenu, index) => (
162167
<SubMenuListItem key={index}>
163-
<Link href={getPath(subMenu.path)}>
168+
<BlockLink href={getPath(subMenu.path)}>
164169
{t(`pageTitle:${subMenu.name}`)}
165-
</Link>
170+
</BlockLink>
166171
</SubMenuListItem>
167172
))}
168173
</SubMenuList>
169174
</ListItem>
170175
) : (
171176
<ListItem key={index} active={isActive(route)}>
172-
<Link href={getPath(route.path)}>
177+
<BlockLink href={getPath(route.path)}>
173178
{t(`pageTitle:${route.name}`)}
174-
</Link>
179+
</BlockLink>
175180
</ListItem>
176181
)
177182
})}

frontend/components/service/Program/CategoryList.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const CategoryList = (props: { list: ITalkList }) => {
2020
categoryList[talk.category].talkList.push(talk)
2121
})
2222

23-
console.log(categoryList)
2423
return (
2524
<>
2625
{Object.keys(categoryList).map((key, index) => (

0 commit comments

Comments
 (0)