@@ -26,20 +26,30 @@ import ArrowIcon from '../../images/arrow.svg?react'
2626
2727import './NavbarLink.scss'
2828
29-
30- const NavbarLink = ( { externalLink = false , icon = null , index = null , label, link = '' , selectedIndex = null , setSelectedIndex, ...props } ) => {
29+ const NavbarLink = ( {
30+ externalLink = false ,
31+ icon = null ,
32+ index = null ,
33+ label,
34+ link = '' ,
35+ selectedIndex = null ,
36+ setSelectedIndex,
37+ ...props
38+ } ) => {
3139 const { pathname } = useLocation ( )
3240
3341 const parentLinkClasses = classNames (
3442 'nav-link__button btn nav-link__parent' ,
35- ( pathname . includes ( props . id || link ) || props ?. screens && props . screens . some ( screen => pathname . includes ( screen ) ) ) && 'active' ,
43+ ( pathname . includes ( props . id || link ) ||
44+ ( props ?. screens && props . screens . some ( screen => pathname . includes ( screen ) ) ) ) &&
45+ 'active' ,
3646 index === selectedIndex && 'expended'
3747 )
3848
3949 const handleExpanded = ( ) => {
4050 if ( setSelectedIndex ) {
4151 if ( index !== selectedIndex ) {
42- setSelectedIndex ( index )
52+ setSelectedIndex ( index )
4353 } else {
4454 setSelectedIndex ( null )
4555 }
@@ -63,7 +73,12 @@ const NavbarLink = ({ externalLink = false, icon = null, index = null, label, li
6373 </ span >
6474 </ div >
6575 ) : (
66- < NavLink to = { link } onClick = { handleExpanded } className = "nav-link__button btn" activeclassname = "active" >
76+ < NavLink
77+ to = { link }
78+ onClick = { handleExpanded }
79+ className = "nav-link__button btn"
80+ activeclassname = "active"
81+ >
6782 < span className = "nav-link__icon" > { icon } </ span >
6883 < span className = "nav-link__label" > { label } </ span >
6984 </ NavLink >
@@ -80,7 +95,7 @@ NavbarLink.propTypes = {
8095 nestedLinks : PropTypes . array ,
8196 screens : PropTypes . array ,
8297 selectedIndex : PropTypes . number ,
83- setSelectedIndex : PropTypes . func ,
98+ setSelectedIndex : PropTypes . func
8499}
85100
86101export default React . memo ( NavbarLink )
0 commit comments