reactjs 在react-markdown中使用rehype-raw解析类型不匹配的HTML元素

ecr0jaav  于 5个月前  发布在  React
关注(0)|答案(1)|浏览(70)

我在我的react项目中使用了typescript,但是当我使用这个代码片段时,我得到了一个错误

<ReactMarkdown rehypePlugins={[rehypeRaw]}>
   {content}
</ReactMarkdown>



Type '(options?: void | Options | undefined) => void | Transformer<Root, Root>' is not assignable to type 'Pluggable<any[], Settings>'.
  Type '(options?: void | Options | undefined) => void | Transformer<Root, Root>' is not assignable to type 'Plugin<any[], Settings>'.
    Type 'void | Transformer<Root, Root>' is not assignable to type 'void | Transformer'.
      Type 'Transformer<Root, Root>' is not assignable to type 'void | Transformer'.
        Type 'Transformer<Root, Root>' is not assignable to type 'Transformer'.
          Types of parameters 'node' and 'node' are incompatible.

字符串
有什么想法关于这个类型的错误吗?

1cosmwyk

1cosmwyk1#

我得到了同样的错误。我通过为rehypePlugins添加类型Assertas any来修复它。

<Markdown
  rehypePlugins={[rehypeRaw] as any}
>
  {content}
</Markdown>

字符串
它现在起作用了。希望它对你也起作用。

相关问题