Ikhlak S.
Ikhlak S.

Reputation: 9034

Typescript set type annotation of JSX

How would I set a type annotation of JSX?

I want to check if props received are type of JSX and not any other type.

This is what my interface looks like:

interface ITextEditorProps{
  value: any
}

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

Upvotes: 4

Views: 758

Answers (1)

Murat Karag&#246;z
Murat Karag&#246;z

Reputation: 37594

There is a type JSX.Element for a broader approach or directly with React.ReactElement<type>

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

Upvotes: 4

Related Questions