원하는 카테고리를 클릭 했을 때 선택 된 카테고리에 CSS를 줘야한다.
<div className="navBottom">
<ul className="categoryList">
{CATEGORIES.map((CATEGORY, i) => (
<Category category={CATEGORY} key={i} />
))}
</ul>
</div>
import React from 'react';
const Category = ({ category }) => {
return (
<li>
<Link to={category.url}>
{category.title}
</Link>
</li>
);
};
export default Category;
import React from 'react';
import { NavLink } from 'react-router-dom';
const Category = ({ category }) => {
return (
<li>
<NavLink
to={category.url}
className={({ isActive }) =>
isActive ? 'categoryActive' : 'categoryTitle'
}
>
{category.title}
</NavLink>
</li>
);
};
export default Category;