【发布时间】:2021-11-06 05:09:38
【问题描述】:
小组件如下所示:
// @flow
import ReactMarkdown from "react-markdown";
import type { Node } from "react";
function LinkRenderer(props: any) {
return (
<a href={props.href} target="_blank" rel="noreferrer">
{props.children}
</a>
);
}
type Props = {
children: Node,
};
const MarkdownRenderer = ({ children }: Props) => {
return (
<ReactMarkdown components={{ link: LinkRenderer }}>
{children}
</ReactMarkdown>
);
};
谁能指出为什么我的链接在使用这个组件时没有在新标签页中打开?
在其他组件中像这样实现该组件:
<MarkdownRenderer>{value}</MarkdownRenderer>
【问题讨论】:
标签: javascript reactjs hyperlink react-markdown