Open ChenPt opened 4 years ago
想要支持组件类作为参数传给组件,一开始编写的是
组件类
// index.d.ts export interface IProps { CheckBox?: CheckBox } declare class CheckBox extends React.Component<ChexkBoxProps> { render(): JSX.Element; } // index.tsx const { CheckBox } = this.props; <CheckBox /> 引用时会提示 `JSX元素类型'CheckBox'没有任何构造或调用签名”`
查询资料得知 组件类作为参数需要如下写法
declare class CheckBox extends React.Component<ChexkBoxProps> { render(): JSX.Element; } export type CheckBoxComp = CheckBox<ChexkBoxProps>; export interface IProps { CheckBox?: CheckBoxComp; // 将组件类作为参数 }
想要支持
组件类
作为参数传给组件,一开始编写的是查询资料得知 组件类作为参数需要如下写法