4

I have upgraded react and react-dom (and also @type/react and @types/react-dom) to the latest version to use react hooks. But now I am getting this type error:

Argument of type typeof is not assignable to parameter of type 'ComponentType< Props & RouteComponentProps<{}, StaticContext, any>>

interface LoginProps {}

class Login extends React.PureComponent<LoginProps & RouteComponentProps, {}> {

}

export default withRouter(Login);

I suspect the type definitions to be the issue, but I cannot find out what.

1 Answer 1

1

I think the problem is with the way you have tried to extend your interface.

In typescript interfaces can be extended using the extends keyword (ie interfaceA extends interfaceB) while types can be extended using the method you have used (ie typeA & typeB).

And since your LoginProps is an interface, your code is breaking.

try rewriting your code as

interface LoginProps extends RouteComponentProps {}

class Login extends React.PureComponent<LoginProps, {}> {

}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.