简体   繁体   English

Typescript 设置 JSX 的类型注解

[英]Typescript set type annotation of JSX

How would I set a type annotation of JSX?我将如何设置 JSX 的类型注释?

I want to check if props received are type of JSX and not any other type.我想检查收到的道具是否是 JSX 类型而不是任何其他类型。

This is what my interface looks like:这是我的界面的样子:

interface ITextEditorProps{
  value: any
}

// Component 
<TextEditor value={<div><h1>Hello World</h1></div>} />

There is a type JSX.Element for a broader approach or directly with React.ReactElement<type>有一个类型JSX.Element用于更广泛的方法或直接使用React.ReactElement<type>

interface ITextEditorProps {
    value: JSX.Element // React.ReactElement<type> also possible
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM