resolve React key duplication warning in Breadcrumb component
This commit is contained in:
parent
1d43470783
commit
b71ca1c7fb
@ -3,30 +3,32 @@ import { useNavigate } from "react-router-dom";
|
||||
|
||||
const Breadcrumb = ({ data }) => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
return (
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol className="breadcrumb breadcrumb-custom-icon">
|
||||
{data.map((item, index) =>
|
||||
{data.map((item, index) => (
|
||||
item.link ? (
|
||||
<li className="breadcrumb-item cursor-pointer" key={index}>
|
||||
<a
|
||||
aria-label="breadcrumb link link-underline-primary "
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
aria-label="breadcrumb link"
|
||||
onClick={() => navigate(item.link)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') navigate(item.link);
|
||||
}}
|
||||
>
|
||||
{item.label}
|
||||
</a>
|
||||
<i className="breadcrumb-icon icon-base bx bx-chevron-right align-middle"></i>
|
||||
</li>
|
||||
) : (
|
||||
<li
|
||||
className="breadcrumb-item active "
|
||||
key={new Date().getMilliseconds()}
|
||||
>
|
||||
{" "}
|
||||
<li className="breadcrumb-item active" key={index}>
|
||||
{item.label}
|
||||
</li>
|
||||
)
|
||||
)}
|
||||
))}
|
||||
</ol>
|
||||
</nav>
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user