【发布时间】:2021-12-16 18:13:04
【问题描述】:
我对函数参数的类型声明有疑问。请看下面的代码,
const FunctionalComponent = ({propA,propB}: FunctionalComponentProps): JSX.Element => {
return
}
现在我想将 FunctionalComponent 作为参数传递给另一个函数。我应该如何声明参数类型?
const Foo = (
para1: string,
TheFunctionalComponent: ??? // Tried React.FC<any>, it work, want to provide more strict such as React.FC<FunctionalComponentProps>, this way it does not work. Is the React.FC<any> the only way?
)
【问题讨论】:
-
看看这篇文章的答案,这可能会有所帮助。 stackoverflow.com/questions/58093669/…
标签: reactjs typescript react-functional-component