Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 如何在React with Typescript中将JSX元素作为Prop传递?_Reactjs_Typescript - Fatal编程技术网

Reactjs 如何在React with Typescript中将JSX元素作为Prop传递?

Reactjs 如何在React with Typescript中将JSX元素作为Prop传递?,reactjs,typescript,Reactjs,Typescript,我想将图标作为道具传递给我的TextInput组件,如下所示: 导出接口TextInputProps{ leadingIcon?:(props:React.ComponentProps)=>JSX.Element } export const TextInputField=forwardRef({leadingcon,…props},ref)=>{ 常数引线图标=引线图标 返回( {领先图标( ):null} ) } 我想这样使用它 但我总是会遇到typescript错误: JSX ele

我想将图标作为道具传递给我的TextInput组件,如下所示:

导出接口TextInputProps{
leadingIcon?:(props:React.ComponentProps)=>JSX.Element
}
export const TextInputField=forwardRef({leadingcon,…props},ref)=>{
常数引线图标=引线图标
返回(
{领先图标(
):null}
)
}
我想这样使用它


但我总是会遇到typescript错误:

JSX element type 'LeadingIcon' does not have any construct or call signatures .ts(2604)

我需要更改什么才能使其正常工作?

尝试:
引导图标?:React.ElementType
谢谢,但我已经尝试过了。Typescript仍然显示相同的错误抱歉。您的问题需要使用
React.ElementType
抱歉,再次出现相同的错误您可以尝试
leadingIcon吗?:React.ComponentType
。抱歉,相同的错误:“JSX元素类型'leadingIcon'没有任何构造或调用签名。”然后尝试将其作为组件传递