小组件看起来像这样:
// @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>