有奇怪的打字稿错误:
类型‘type of Filter’的
参数不能分配给'Component‘类型的参数。类型‘Type not Filter’不能分配到键入'ComponentClass‘。构造签名返回类型'Filter‘和'Component’是不兼容的。“道具”的类型在这些类型之间是不兼容的。键入“Readonly& Readonly<{子?:ReactNode;}>”不能指定键入“从不”. is (2345)
下面是基本代码:
import React from "react";
import { connect } from "react-redux";
import { RootState } from "typesafe-actions";
const mapStateToProps = (state: RootState) => ({
common: state.common,
});
type Props = {
children: JSX.Element[];
} & ReturnType<typeof mapStateToProps>;
type State = {
showFilter: boolean;
};
class Filter extends React.Component<Props, State> {
render() {
return <>{this.props.children}</>;
}
}
export default connect(mapStateToProps, null)(Filter);我真的不知道为什么会这样。任何关于它的指示都是非常感谢的!谢谢您:)
发布于 2021-05-12 23:44:40
我要做的就是:
export default connect(mapStateToProps)(Filter);
https://stackoverflow.com/questions/67511499
复制相似问题