代码之家  ›  专栏  ›  技术社区  ›  Matt

createPortal属性“children”在类型中缺失,但在类型“ReactPortal”中是必需的

  •  0
  • Matt  · 技术社区  · 1 年前

    我正试图将一个元素传送到 document.body 但打字稿声称

    Property 'children' is missing in type 'ReactElement<any, string | JSXElementConstructor<any>>' but required in type 'ReactPortal'.
    

    如何修复这个createPortal键入错误?

    enter image description here

    它甚至不适用于像这样的原生HTML元素 <p> 如下图所示。

    enter image description here

    1 回复  |  直到 1 年前
        1
  •  0
  •   Matt    1 年前

    createPortal 在NextJS组件中不起作用