其他分享
首页 > 其他分享> > Cannot read properties of undefined (reading 'setState')

Cannot read properties of undefined (reading 'setState')

作者:互联网

 

this的指向不对,需要用bind绑定this

例如

constructor(props){
    super(props)
    
    this.state=store.getState()
    this.changeInputValue=this.changeInputValue.bind(this)//绑定
    store.subscribe(this.storeChange)//订阅
  }

 

标签:storeChange,绑定,undefined,read,bind,props,Cannot,changeInputValue,store
来源: https://www.cnblogs.com/Jarsmine/p/16389812.html