【发布时间】:2018-01-01 12:37:24
【问题描述】:
import * as React from 'react';
import {connect} from 'react-redux';
interface types{
type:string;
status?:boolean;
}
export class Test extends React.Component<undefined,any> {
constructor(props:undefined){
super(props);
}
private test(){}
render(){
return(
<h1 onClick={this.test.bind(this)}>
test
</h1>
)
}
}
export default connect()(Test);
错误
“typeof test”类型的参数不可分配给“Component'。
【问题讨论】:
-
欢迎来到 Stackoverflow!请花一些时间阅读the help pages,尤其是名为"What topics can I ask about here?" 和"What types of questions should I avoid asking?" 的部分。也请使用tour 并阅读有关how to ask good questions 的信息。最后请学习如何创建Minimal, Complete, and Verifiable Example。
-
我有点困惑,为什么您需要将此组件连接到 redux。您没有提供函数来连接 redux 状态或分派到组件的 props。您实际上可以完全删除
connect调用。至于错误,那是因为你的 props 设置为undefined并且没有实现任何必需的属性。
标签: reactjs typescript redux react-redux