Reputation: 123
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.
Upvotes: 4
Views: 202
Reputation: 3098
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, {}> {
}
Upvotes: 1