Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未捕获类型错误:this.handleSearchNext不是函数_Javascript_Reactjs_This - Fatal编程技术网

Javascript 未捕获类型错误:this.handleSearchNext不是函数

Javascript 未捕获类型错误:this.handleSearchNext不是函数,javascript,reactjs,this,Javascript,Reactjs,This,我正在尝试覆盖handsontable的keyEvent。 代码运行,但将得到错误 “未捕获类型错误:this.handleSearchNext不是函数” 但它是一个定义的函数,所以我不确定为什么会出现这个错误 async componentWillReceiveProps(newProps) { this.hotTable.updateSettings({ afterDocumentKeyDown(e) { if (e.key === 'Enter') {

我正在尝试覆盖handsontable的keyEvent。 代码运行,但将得到错误 “未捕获类型错误:this.handleSearchNext不是函数” 但它是一个定义的函数,所以我不确定为什么会出现这个错误

async componentWillReceiveProps(newProps) {
    this.hotTable.updateSettings({
      afterDocumentKeyDown(e) {
        if (e.key === 'Enter') {
          this.handleSearchNext(e)
          e.stopPropagation()
          console.log('Stopped propigation in table', e)
        }
      }
    })
}
.
.
.
handleSearchNext = (e) => {...}

您必须将方法绑定到
this
:在构造函数中:
this.handleSearchNext=this.handleSearchNext.bind(this)可能重复@RandyCasburn,因为它是一个箭头函数,所以不需要特别绑定。不是()=>自动绑定函数吗?您必须将方法绑定到
this
:在构造函数中:
this.handleSearchNext=this.handleSearchNext.bind(this)可能重复@RandyCasburn,因为它是一个箭头函数,所以不需要特别绑定。()=>是否自动绑定函数?