我需要使用如下自定义接口(interface)扩展 React.FC
:
interface IComponent<P = {}> extends React.FC {
custom?: {a: string, b: string};
}
const Page:IComponent<{text: string}> = ({text}) => (
<>{text}</>
)
Page.custom = {a: '1', b: '2'}
Page.custom
输入正确,但 React.FC
Prop 功能丢失。我该如何解决这个问题?
最佳答案
想通了。我需要将 P
参数从 IComponent
传递到 React.FC
interface IComponent<P = {}> extends React.FC<P> {
custom?: {a: string, b: string};
}
关于reactjs - Typescript 接口(interface)扩展了 React.FC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66510135/