Reactjs 类型为'的参数;类型-';不可分配给ComponentClass错误类型的参数
我正在为React/Redux项目设置TypeScript 按照标准的Redux模式,我有一个组件Foo和一个组件容器FooContainerReactjs 类型为'的参数;类型-';不可分配给ComponentClass错误类型的参数,reactjs,typescript,redux,Reactjs,Typescript,Redux,我正在为React/Redux项目设置TypeScript 按照标准的Redux模式,我有一个组件Foo和一个组件容器FooContainer // Foo Component file interface FooProps { fooProp: string <-- I think props have something to do with the issue } class Foo extends React.Component<FooProps, {}>
// Foo Component file
interface FooProps {
fooProp: string <-- I think props have something to do with the issue
}
class Foo extends React.Component<FooProps, {}> {
...
}
// in FooContainer file
...
const FooContainer =
connect(mapStateToProps,mapDispatchToProps)(Foo <--)
// Foo throws TypeScript error
// Argument of type 'typeof Foo' is not assignable
// to parameter of type 'ComponentClass
//Foo组件文件
界面道具{
fooProp:string你的mapStateToProps和mapDispatchToProps看起来像什么?它们的类型是什么?它们都没有可能是问题的类型…将连接类型设置为使错误消失,但实际上似乎不是正确的方法。希望这是一条线索,让我找到解决问题的途径。让你的操作成为典型e any,以及您在这两个函数中的状态,看看会发生什么。不要更改连接函数类型