Reactjs React-Redux connect不可分配给类型';()=>;无效';用打字稿

Reactjs React-Redux connect不可分配给类型';()=>;无效';用打字稿,reactjs,typescript,redux,Reactjs,Typescript,Redux,一切都好吗 我对理解一个问题感到困惑,使用带有react的键入文本,当连接或重新复制组件时,它会出现此错误,我无法理解,做一些研究,但答案相当混乱 错误如下: Argument of type 'typeof Beds' is not assignable to parameter of type 'ComponentType<Matching<{ beds: DataBedsTypes[]; } & typeof import("/Users/keven/Documents

一切都好吗

我对理解一个问题感到困惑,使用带有react的键入文本,当连接或重新复制组件时,它会出现此错误,我无法理解,做一些研究,但答案相当混乱

错误如下:

Argument of type 'typeof Beds' is not assignable to parameter of type 'ComponentType<Matching<{ beds: DataBedsTypes[]; } & typeof import("/Users/keven/Documents/carenet/orquestra-frontend/src/Beds/action"), Props>>'.
  Type 'typeof Beds' is not assignable to type 'ComponentClass<Matching<{ beds: DataBedsTypes[]; } & typeof import("/Users/keven/Documents/carenet/orquestra-frontend/src/Beds/action"), Props>, any>'.
    Types of parameters 'props' and 'props' are incompatible.
      Type 'Matching<{ beds: DataBedsTypes[]; } & typeof import("/Users/keven/Documents/carenet/orquestra-frontend/src/Beds/action"), Props>' is not assignable to type 'Readonly<Props>'.
        Types of property 'loadBeds' are incompatible.
          Type '(data: DataBedsTypes[]) => { type: BedsTypes; payload: DataBedsTypes[]; }' is not assignable to type '() => void'.  TS2345

    46 |   mapStateToProps,
    47 |   mapDispatchToProps,
  > 48 | )(Beds);
类型为“typeof Beds”的参数不能分配给类型为“ComponentType”的参数。
类型“typeof Beds”不可分配给类型“ComponentClass”。
参数“props”和“props”的类型不兼容。
类型“Matching”不可分配给类型“Readonly”。
属性“装载床”的类型不兼容。
Type'(data:DataBedsTypes[])=>{Type:BedsTypes;payload:DataBedsTypes[];}'不可分配给类型'()=>void'。TS2345
46 | mapStateToProps,
47 | mapDispatchToProps,
>48 |)(床位);
我的组件

import React, { Component } from 'react';

import { connect } from 'react-redux';
import { bindActionCreators, Dispatch } from 'redux';
import { Row, Col } from 'config/styles';
import { ApplicationState } from 'config/store';
import { DataBedsTypes } from './types';
import * as BedsActions from './action';

import Bed from './Bed';

interface StateProps {
  beds: DataBedsTypes[];
}

interface DispatchProps {
  loadBeds(): void;
}

type Props = StateProps & DispatchProps;

class Beds extends Component<Props> {
  componentWillMount() {
    const { loadBeds } = this.props;
    loadBeds();
  }

  render() {
    const { beds } = this.props;
    return (
      <Row>
        {beds.map((b: DataBedsTypes) => (
          <Col key={b.pid} md={16.666} lg={10}>
            <Bed {...b} />
          </Col>
        ))}
      </Row>
    );
  }
}

const mapStateToProps = (state: ApplicationState) => ({ beds: state.beds.data });
const mapDispatchToProps = (dispatch: Dispatch) => bindActionCreators(BedsActions, dispatch);

export default connect(
  mapStateToProps,
  mapDispatchToProps,
)(Beds);
import React,{Component}来自'React';
从'react redux'导入{connect};
从“redux”导入{bindActionCreators,Dispatch};
从'config/styles'导入{Row,Col};
从'config/store'导入{ApplicationState};
从“./types”导入{DataBedsTypes};
将*作为操作从“./action”导入;
从“./床”导入床;
接口状态道具{
床位:数据床位[];
}
界面分派道具{
荷载床():空隙;
}
类型Props=StateProps和DispatchProps;
类扩展组件{
组件willmount(){
const{loadBeds}=this.props;
装载床();
}
render(){
const{beds}=this.props;
返回(
{beds.map((b:DataBedsTypes)=>(
))}
);
}
}
const-mapStateToProps=(state:ApplicationState)=>({beds:state.beds.data});
const mapDispatchToProps=(调度:调度)=>bindActionCreators(操作,调度);
导出默认连接(
MapStateTops,
mapDispatchToProps,
)(床位);

您的DispatchProp界面错误。现在你说的是荷载床类型为void。您的界面应该是这样的

interface DispatchProps {
  loadBeds: () => void;
}