我正在使用 mongodb、express 和 React 创建注册登录模块,但在创建此模块时遇到属性历史记录不存在错误:
类型“Readonly & Readonly<{children?: ReactNode;”上不存在属性“history” }>'.ts(2339)
import React, { Component } from 'react'
import { login } from './userfunctions'
interface userprops{}
interface data{
email:string;
password:string;
errors: string;
}
Run Code Online (Sandbox Code Playgroud)
//主类:
class Login extends Component<userprops, data> {
constructor(props: userprops) {
super(props)
this.state = {
email: '',
password:'',
errors: ''
}
this.onChange = this.onChange.bind(this) //binding the function
this.onSubmit = this.onSubmit.bind(this) //binding the function
}
onChange(e:any) { //on change function
this.setState({ email: e.target.value })
}
onSubmit(e:any) { //on submitting the …Run Code Online (Sandbox Code Playgroud)