Skip to content

Commit 7d58aee

Browse files
committed
(#6140) Review changes
1 parent 25a6f41 commit 7d58aee

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

dev/src/components/docs/ComponentList.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { FC, MouseEvent, KeyboardEvent } from 'react';
1+
import type { FC } from 'react';
22
import React, { Suspense, useEffect, useState, useRef, useCallback } from 'react';
33
import { useDocsPreferredVersion } from '@docusaurus/theme-common';
4-
import { useHistory } from 'react-router-dom';
4+
import Link from '@docusaurus/Link';
55
import { KolCard, KolHeading } from '@public-ui/react';
66

77
import type { Language } from '../../shares/language';
@@ -20,7 +20,6 @@ const LazyLoadComponent: FC<
2020
observer: (cb: () => void) => IntersectionObserver;
2121
}
2222
> = ({ name, lang, path, loadComponent, observer }) => {
23-
const history = useHistory();
2423
const ref = useRef<HTMLDivElement>(null);
2524
const [isVisible, setIsVisible] = useState<boolean>(false);
2625

@@ -30,17 +29,6 @@ const LazyLoadComponent: FC<
3029

3130
const formattedComponentName = name.charAt(0).toUpperCase() + name.slice(1);
3231

33-
const handleRedirect = useCallback(
34-
(event: MouseEvent<HTMLAnchorElement> | KeyboardEvent<HTMLAnchorElement>) => {
35-
if (event.type === 'click' || (event.type === 'keydown' && (event as React.KeyboardEvent).key === 'Enter')) {
36-
event.preventDefault();
37-
history.push(`${path ?? '/docs/next'}/components/${formattedComponentName}`);
38-
}
39-
return event;
40-
},
41-
[path, formattedComponentName]
42-
);
43-
4432
const SampleComponent = loadComponent();
4533
if (!loadComponent) {
4634
throw new Error(`Example component for ${name} not found`);
@@ -49,7 +37,7 @@ const LazyLoadComponent: FC<
4937
<div ref={ref} className="components-overview-item">
5038
{isVisible && (
5139
<Suspense fallback={<div className="skeleton"></div>}>
52-
<a tabIndex={0} onKeyDown={handleRedirect} onClick={handleRedirect}></a>
40+
<Link tabIndex={0} to={`${path ?? '/docs/next'}/components/${formattedComponentName}`} />
5341
<KolCard
5442
tabIndex={-1}
5543
aria-label={formattedComponentName}

0 commit comments

Comments
 (0)