Skip to content

Commit 48e2588

Browse files
authored
fixed key errors on tutorials page (base#598)
1 parent 100e760 commit 48e2588

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

apps/base-docs/src/pages/tutorials/index.jsx

+18-4
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,27 @@ function TagChip({ tag, isSelected, setSelectedTag }) {
4343
);
4444
}
4545

46+
const handleContainerClick = (event, tutorial, history) => {
47+
if (event.target.closest('a')) return;
48+
history.push(`/tutorials${tutorial.slug}`)
49+
}
50+
4651
const handleClick = (event) => {
4752
event.stopPropagation();
4853
};
4954

5055
function TutorialListCell({ tutorial }) {
56+
const history = useHistory()
5157
const authorData = authors[tutorial.author];
5258
return (
53-
<Link to={`/tutorials${tutorial.slug}`}>
59+
// <Link to={`/tutorials${tutorial.slug}`}>
60+
<div
61+
onClick={(event) => {
62+
handleContainerClick(event, tutorial, history)
63+
}}
64+
role="button"
65+
tabIndex={0}
66+
>
5467
<div className={clsx(styles.tutorialListCell, 'container')}>
5568
<header>
5669
<h2 className={clsx(styles.tutorialListTitle)}>{tutorial.title}</h2>
@@ -73,10 +86,11 @@ function TutorialListCell({ tutorial }) {
7386
)}
7487
<div className={clsx(styles.tutorialListCellInfo)}>
7588
{tutorial.tags &&
76-
tutorial.tags.map((tag) => <p className={clsx(styles.tutorialListTag)}>{tag}</p>)}
89+
tutorial.tags.map((tag) => <p key={tag} className={clsx(styles.tutorialListTag)}>{tag}</p>)}
7790
</div>
7891
</div>
79-
</Link>
92+
</div>
93+
// </Link>
8094
);
8195
}
8296

@@ -130,7 +144,7 @@ export default function Tutorials() {
130144
.filter((tutorial) =>
131145
selectedTag == 'all' ? tutorial : tutorial.tags.includes(selectedTag),
132146
)
133-
.map((tutorial) => <TutorialListCell tutorial={tutorial} />)}
147+
.map((tutorial) => <TutorialListCell key={tutorial.slug} tutorial={tutorial} />)}
134148
</div>
135149
</div>
136150
</div>

0 commit comments

Comments
 (0)