Javascript 更新react和react dom后的Typescript错误
我已将react和react dom(以及@type/react和@types/react dom)升级到最新版本,以使用react挂钩。但现在我得到了这种类型的错误: 类型为typeof的参数不可分配给类型为的参数 'ComponentTypeJavascript 更新react和react dom后的Typescript错误,javascript,reactjs,typescript,Javascript,Reactjs,Typescript,我已将react和react dom(以及@type/react和@types/react dom)升级到最新版本,以使用react挂钩。但现在我得到了这种类型的错误: 类型为typeof的参数不可分配给类型为的参数 'ComponentType 接口登录操作{} 类登录扩展了React.PureComponent{ } 使用路由器导出默认值(登录); 我怀疑类型定义是问题所在,但我无法找出原因。我认为问题在于您试图扩展接口的方式 在类型脚本中,可以使用extends关键字(即interfac
接口登录操作{}
类登录扩展了React.PureComponent{
}
使用路由器导出默认值(登录);
我怀疑类型定义是问题所在,但我无法找出原因。我认为问题在于您试图扩展接口的方式 在类型脚本中,可以使用
extends
关键字(即interfaceA extends interfaceB
)扩展接口,而类型可以使用您使用的方法(即typeA&typeB
)扩展
由于您的LoginProps是一个接口,因此您的代码正在中断
尝试将代码重写为
interface LoginProps extends RouteComponentProps {}
class Login extends React.PureComponent<LoginProps, {}> {
}
接口登录操作扩展了RouteComponentProps{}
类登录扩展了React.PureComponent{
}
interface LoginProps extends RouteComponentProps {}
class Login extends React.PureComponent<LoginProps, {}> {
}