React TypeError this._test is not a function

前端 未结 3 1764
天涯浪人
天涯浪人 2020-12-03 11:11

Since im new to JavaScript and React, i really have problems figuring out the right syntax.

Here my problem:

_handleDrop(files) should call the

3条回答
  •  -上瘾入骨i
    2020-12-03 12:09

    The way we solved this issue is to use an experimental es7 feature which lets you declare a function in this way within a class:

    handleExpandCollapse = () => {
        this.setState({
          isExpanded: !this.state.isExpanded,
        });
      }
    

    And that is autobound to this, so your JSX will be the same.

提交回复
热议问题