理解Typescript中的React.FC

理解Typescript中的React.FC,typescript,react-typescript,Typescript,React Typescript,我一直在尝试了解React.FC类型是如何工作的,并尝试了多种方法这是唯一有效的方法: import React from 'react' type iProps<P = {}> = { (props: P): React.ReactElement<any, any> } interface IPropsTest { name: string, age: number }

我一直在尝试了解React.FC类型是如何工作的,并尝试了多种方法这是唯一有效的方法:

import React from 'react'
    
    type iProps<P = {}> = {
        (props: P): React.ReactElement<any, any>
    }
    
    interface IPropsTest {
        name: string,
        age: number
    }
    
    const MyComponent: iProps<IPropsTest> = ({ name, age }) => {
        return <div>{name} {age}</div>
    }
从“React”导入React
类型iProps={
(道具:P):React.React元素
}
接口IPropsTest{
名称:string,
年龄:数目
}
常量MyComponent:iProps=({name,age})=>{
返回{name}{age}
}
有人能解释一下这部分吗

type iProps<P = {}> = {
    (props: P): React.ReactElement<any, any>
}
类型iProps={
(道具:P):React.React元素
}
为什么我需要
,为什么我必须把
(props:p)

什么是
p={}
这是一个通用默认值。如果未提供泛型参数,则假定
P
{}

为什么我要把
(道具:P)

这意味着可以使用一个类型为
p

的参数调用函数,您想做什么?您甚至没有使用
FC
类型hered您在概念上理解Typescript泛型吗?如果没有,就从那里开始。