我将一个函数组件传递给高阶组件,该函数组件具有一些静态属性作为示例!如何从返回的组件中获取静态属性!
function TestHighOrderCp<T>(
Cp: React.ComponentType<T>
): (
props: T & {
name: string
}
) => JSX.Element {
const rs = (props: T & { name: string }) => {
const name = 'testName'
return <Cp name={name} {...props} />
}
return rs
}
const A1 = function A1(props: { e: string }) {
return <div>{props.e}</div>
}
A1.defaultProps = {
e: 12
}
A1.name = '12'
const A11 = TestHighOrderCp<A1>
// A11.Name = {} // get Error here