React Native: this.setState is not a function

前端 未结 5 1952
礼貌的吻别
礼貌的吻别 2020-12-29 22:01

I see a number of questions on here relating to this same issue, but it seems none match the issue I\'m having, and are a bit more complex.

I am in the process of le

5条回答
  •  时光说笑
    2020-12-29 22:14

    I had the same problem when trying to set the state. when I bind the function inside the constructor, the issue gets solved. check with below binding

     constructor(props) {
        super(props);
        this.state = {
          zip: "",
          forecast: null
        };
    
       this._handleTextChange = this._handleTextChange.bind(this);
    
      }
    

提交回复
热议问题