The parameter "key"val" implicitly has the type "any".

look at some materials but do not understand, the company requires to write in typescript, who can answer
clipboard.png

clipboard.png

problem description

The

parameter "key"val" implicitly has the type "any".
history does not exist and I am invalid if I use prop-types

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)
import * as React from "react";
/ / import PropTypes from "prop-types";
export interface Props {

user: string;
pwd?: string;
key :any;

}

interface State {

user: string;
pwd?: string;

}
class Login extends React.Component < Props, State > {

constructor(props: Props) {
    super(props)
    this.state = {
        user: "",
        pwd: ""
    }
    this.register = this.register.bind(this)
}
register(){
    this.props.history.push("/register")
}
onInputChange(key,val) {
    this.setState({
        [key]:val
    })
    // // console.log(event.target.value)
    // this.setState({})
}
// handleLogin(){
//     this.props.login(this.state)
// }
render() {
    return (
        <div>
            <form>
                <div>
                    <label>:</label>
                    <input type="text" placeholder="" value={this.state.user} onChange={v => this.onInputChange("user",v)} />
                </div>
                <div>
                    <label>:</label>
                    <input type="text" placeholder="" value={this.state.pwd} onChange={v => this.onInputChange("pwd",v)} />
                </div>
                <button onClick={this.register}></button>
            </form>
        </div>
    )
}

}
/ / Login.propTypes = {
/ / register: PropTypes.string
/ /};

export default Login;

what result do you expect? What is the error message actually seen?

Jul.14,2021

  

No, the same mistakes

Menu