如何解决如何键入Reactstrap Spinner的Wrapper react函数?
我尝试为Spinner制作自定义默认道具,所以我尝试制作channel_id
接口,该接口扩展了Reactstrap的SpinnerAProps
,Spinner也使用类似以下方法:
SpinnerProps
这是Reactstrap的SpinnerProps
declare class Spinner<T = {[key: string]: any}> extends React.Component<SpinnerProps> {}
对我来说似乎不错,因为export interface SpinnerProps extends React.HTMLProps<HTMLElement> {
[key: string]: any;
tag?: string | React.ReactType;
type?: string;
size?: any;
color?: string;
className?: string;
cssModule?: CSSModule;
}
接口使用相同的接口
但它抱怨
SpinnerAProps
No overload matches this call.
Overload 1 of 2,'(props: Readonly<SpinnerProps>): Spinner<{ [key: string]: any; }>',gave the following error.
Type '{ tag?: string | ComponentClass<any,any> | FunctionComponent<any> | undefined; type?: string | undefined; size: any; color?: string | undefined; ... 359 more ...; animation: string; }' is not assignable to type 'IntrinsicClassAttributes<Spinner<{ [key: string]: any;
}>>'.
Types of property 'ref' are incompatible.
Type 'string | ((instance: HTMLElement | null) => void) | RefObject<HTMLElement> | null | undefined' is not assignable to type 'string | ((instance: Spinner<{ [key: string]: any; }> | null) => void) | RefObject<Spinner<{ [key: string]: any; }>> | null | undefined'.
Type '(instance: HTMLElement | null) => void' is not assignable to type 'string | ((instance: Spinner<{ [key: string]: any; }> | null) => void) | RefObject<Spinner<{ [key: string]: any; }>> | null | undefined'.
...
为什么以及如何解决呢?谢谢
我发现了一条线索,它抱怨是由于HTMLProps的AllHTMLAttributes,ClassAttributes
解决方法
我发现从props破坏ref是解决这个问题的方法。 ButtonProps from the package is incompatible with Button component from the package
<div id="some-id">This text will get overwritten by JS</div>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。