ReactJS type error null when typing in input box. creating weather app

Viewed 28

Typing the name of a second city after a previous search yields Type error, cannot read properties of undefined (reading 'state') Line 17

code error

render() { return (
<div>
  <div className="box">
    <div className="inputData">
      <input type="search" className="inputField" onChange={(event)=> { this.setState({ setSearch: event.target.value }); this.setState({ search: event.target.value }); }} onKeyDown={this.componentDidMount} />
    </div>
    <div className="info">
      <h2 className="location">
        <i class="fas fa-street-view"></i> {this.state.setSearch}
      </h2>
      <h1 className="temp">{this.state.setCity?.main?.temp}</h1>
      <h3 className="tempin_max"></h3> Min
    </div>
    <div className="wave -one"></div>
    <div className="wave -two"></div>
    <div className="wave -three"></div>
  </div>
</div>
); } }
0 Answers
Related