/
githubmirror
/
immutable-js
Обзор
Документация
Войти
/
githubmirror
/
immutable-js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
website/src/MarkdownContent.tsx
33 строки
743 B
Julien Deniau
sort all imports via eslint
12 июн 2025, 01:23
12 июн 2025, 01:23
67a4fa9
Код
Авторство
О чём код?
'use client'; import { useRouter } from 'next/navigation'; import { MouseEvent, memo } from 'react'; type Props = { contents: string; className?: string; }; // eslint-disable-next-line prefer-arrow-callback export const MarkdownContent = memo<Props>(function MarkdownContent({ contents, className, }) { const router = useRouter(); const handleClick = (event: MouseEvent) => { const link = event.target as HTMLAnchorElement; if (link.tagName === 'A' && link.target !== '_blank') { event.preventDefault(); router.push(link.href); } }; return ( <div className={'markdown ' + (className || '')} onClick={handleClick} dangerouslySetInnerHTML={{ __html: contents }} /> ); });