Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion www/src/theme/Playground/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { LiveContext, LivePreview } from 'react-live';
import qsa from 'dom-helpers/querySelectorAll';
import useIsomorphicEffect from '@restart/hooks/useIsomorphicEffect';
import useMutationObserver from '@restart/hooks/useMutationObserver';
import useEventCallback from '@restart/hooks/useEventCallback';

export interface PreviewProps {
className?: string | undefined;
Expand Down Expand Up @@ -55,9 +56,15 @@ const Preview: React.FC<PreviewProps> = ({ className }) => {
},
);

const handleCustomRedirect = useEventCallback((e: React.MouseEvent<HTMLElement>) => {
if (e.target.tagName === 'A') {
e.preventDefault();
}
})

return (
<div ref={exampleRef}>
<LivePreview className={className} />
<LivePreview className={className} onClick={handleCustomRedirect}/>
</div>
);
};
Expand Down