1
- import type { FC , MouseEvent , KeyboardEvent } from 'react' ;
1
+ import type { FC } from 'react' ;
2
2
import React , { Suspense , useEffect , useState , useRef , useCallback } from 'react' ;
3
3
import { useDocsPreferredVersion } from '@docusaurus/theme-common' ;
4
- import { useHistory } from 'react-router-dom ' ;
4
+ import Link from '@docusaurus/Link ' ;
5
5
import { KolCard , KolHeading } from '@public-ui/react' ;
6
6
7
7
import type { Language } from '../../shares/language' ;
@@ -20,7 +20,6 @@ const LazyLoadComponent: FC<
20
20
observer : ( cb : ( ) => void ) => IntersectionObserver ;
21
21
}
22
22
> = ( { name, lang, path, loadComponent, observer } ) => {
23
- const history = useHistory ( ) ;
24
23
const ref = useRef < HTMLDivElement > ( null ) ;
25
24
const [ isVisible , setIsVisible ] = useState < boolean > ( false ) ;
26
25
@@ -30,17 +29,6 @@ const LazyLoadComponent: FC<
30
29
31
30
const formattedComponentName = name . charAt ( 0 ) . toUpperCase ( ) + name . slice ( 1 ) ;
32
31
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
-
44
32
const SampleComponent = loadComponent ( ) ;
45
33
if ( ! loadComponent ) {
46
34
throw new Error ( `Example component for ${ name } not found` ) ;
@@ -49,7 +37,7 @@ const LazyLoadComponent: FC<
49
37
< div ref = { ref } className = "components-overview-item" >
50
38
{ isVisible && (
51
39
< 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 } ` } / >
53
41
< KolCard
54
42
tabIndex = { - 1 }
55
43
aria-label = { formattedComponentName }
0 commit comments