[英]Type React: Argument of type 'profile' is not assignable to parameter of type 'ComponentType<never>'
I'm new to typescript and this issues has me stumped. 我是打字稿新手,这个问题让我感到难过。 Here's my code.
这是我的代码。
import { IProps, IState } from './types';
class Profile extends Component<RouteComponentProps & IProps, IState>{
state: IState = {
form: {
first_name: this.props.user.first_name,
last_name : this.props.user.last_name,
email : this.props.user.email,
phone : this.props.user.phone || ''
},
isLoading: false
};
validator = new SimpleReactValidator({autoForceUpdate: true});
render () {
const { user } = this.props;
const { form, isLoading } = this.state;
return (<div></div>)
}
}
export default Profile;
These are my types: 这些是我的类型:
export interface IState {
form: {
[key: string]: any;
};
isLoading: boolean;
}
export interface IProps {
children?: Element;
user : any;
}
And this is my index.ts: 这是我的index.ts:
import Profile from './pages/profile/Profile';
const mapStateToProps = (state: IAppState) => {
return {
user: state.Auth.user
};
};
export default connect(mapStateToProps)(Profile);
My code editor highlights that (Profile) as an error. 我的代码编辑器突出显示该(配置文件)为错误。
My terminal throws out the following error: 我的终端抛出以下错误:
Argument of type 'typeof Profile' is not assignable to parameter of type >'ComponentType'.
类型'typeof Profile'的参数不能分配给类型>'ComponentType'的参数。 Type 'typeof Profile' is not assignable to type 'ComponentClassany>'.
类型'typeof Profile'不能分配给类型'ComponentClassany>'。
I'd like to know if there is a code change I can make here to fix this Typescript "error". 我想知道是否可以在这里进行代码更改以解决此Typescript“错误”。
import { IProps, IState } from './types';
import {connect} from "react-redux"
class Profile extends Component<RouteComponentProps & IProps, IState>{
state: IState = {
form: {
first_name: this.props.user.first_name,
last_name : this.props.user.last_name,
email : this.props.user.email,
phone : this.props.user.phone || ''
},
isLoading: false
};
validator = new SimpleReactValidator({autoForceUpdate: true});
render () {
const { user } = this.props;
const { form, isLoading } = this.state;
return (<div></div>)
}
}
const mapStateToProps = (state: IAppState) => {
return {
user: state.Auth.user
};
};
export default connect(mapStateToProps)(Profile);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.