File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { LiveContext, LivePreview } from 'react-live';
44import qsa from 'dom-helpers/querySelectorAll' ;
55import useIsomorphicEffect from '@restart/hooks/useIsomorphicEffect' ;
66import useMutationObserver from '@restart/hooks/useMutationObserver' ;
7+ import useEventCallback from '@restart/hooks/useEventCallback' ;
78
89export interface PreviewProps {
910 className ?: string | undefined ;
@@ -55,9 +56,15 @@ const Preview: React.FC<PreviewProps> = ({ className }) => {
5556 } ,
5657 ) ;
5758
59+ const handleCustomRedirect = useEventCallback ( ( e : React . MouseEvent < HTMLElement > ) => {
60+ if ( e . target . tagName === 'A' ) {
61+ e . preventDefault ( ) ;
62+ }
63+ } )
64+
5865 return (
5966 < div ref = { exampleRef } >
60- < LivePreview className = { className } />
67+ < LivePreview className = { className } onClick = { handleCustomRedirect } />
6168 </ div >
6269 ) ;
6370} ;
You can’t perform that action at this time.
0 commit comments