pandaHT
pandaHT

Reputation: 33

Argument of type 'typeof test' is not assignable to parameter of type 'Component<{ children?: ReactNode; } & DispatchProp<any>>'

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); 

Error

Argument of type 'typeof test' is not assignable to parameter of type 'Component<{ children?: ReactNode; } & DispatchProp>'. ­­­­­­­­­­­­­­­­­­­­­

Upvotes: 3

Views: 2790

Answers (1)

Simon
Simon

Reputation: 1822

It looks like you're overengineering your component; it doesn't need to connect to redux at all as it doesn't make use of either the state or dispatch. Also, the error itself refers to the fact that the type of props is undefined and so doesn't implement any of the required properties for connected components.

Here's the simplified component:

import * as React from 'react';

export default class Test extends React.Component<{}, {}> {
    private test() {}

    render() {
        return(
            <h1 onClick={this.test.bind(this)}>
                test
            </h1>
        );
    }
}

Upvotes: 1

Related Questions