Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 使用TypeScript扩展React组件类_Reactjs_Typescript_Oop_Generics_Inheritance - Fatal编程技术网

Reactjs 使用TypeScript扩展React组件类

Reactjs 使用TypeScript扩展React组件类,reactjs,typescript,oop,generics,inheritance,Reactjs,Typescript,Oop,Generics,Inheritance,我试图用一个比 这是我的基本类: export class RootContainer< P extends RootContainerProps & RootStateFromProps & RootDispatchFromProps, S extends RootContainerState > extends React.Component<P, S> { constructor(props: P) { super(props);

我试图用一个比

这是我的基本类:

export class RootContainer<
  P extends RootContainerProps & RootStateFromProps & RootDispatchFromProps,
  S extends RootContainerState
> extends React.Component<P, S> {
  constructor(props: P) {
    super(props);
    this.state = this.getInitialState();
  }

  getInitialState(): S {
    return { modalIsOpen: false } as S;
  }
导出类RootContainer<
P扩展RootContainerProps和RootStateFromProps以及RootDispatchFromProps,
S扩展RootContainerState
>扩展React.Component{
建造师(道具:P){
超级(道具);
this.state=this.getInitialState();
}
getInitialState():S{
将{modalIsOpen:false}返回为S;
}
然后我尝试扩展如下:

interface MyReservationsContainerProps extends RootContainerProps {
  // Normal component props
}

interface MyReservationsContainerState extends RootContainerState {
  allReservations: Reservation[];
  selectableReservations: Reservation[];
  mode: number;
}

class MyReservationsContainer extends RootContainer<
  MyReservationsContainerProps,
  MyReservationsContainerState
> {
接口MyReservationsContainerProps扩展了RootContainerProps{
//法向分量道具
}
接口MyReservationsContainerState扩展了RootContainerState{
所有保留:保留[];
selectableReservations:Reservation[];
方式:编号;
}
类MyReservationsContainer扩展了RootContainer<
MyReservationsContainerProps,
MyReservationsContainerState
> {
但我得到了这个错误:

没有基构造函数具有指定数量的类型 参数ts(2508)


任何类型脚本专家都能帮我吗?

所以我找到了答案-问题是基类被包装在redux connect()HOF中,然后被导出,我实际上需要导出标准的non-connect()版本,然后将派生类包装在connect()中之后。这里最好的做法是什么?只是删除这个问题?不,让它打开…我解决了这个问题-问题是基类被包装在redux connect()HOF中,然后被导出,我实际上需要导出标准的non-connect()版本,然后将派生类包装在connect()中之后。这里最好的做法是什么?只是删除这个问题?不,让它开着……帮助了我