最新消息:20210917 已从crifan.com换到crifan.org

【已解决】react-tappable中TappableMixin.js报错:Uncaught TypeError this.setState is not a function

ReactJS crifan 2311浏览 0评论

折腾:

【已解决】ReactJS中如何实现长按某行显示内容

期间,结果发现:

react-tappable中TappableMixin.js

有代码有问题

TappableMixin.js?81b1:92 Uncaught TypeError: this.setState is not a function
    at Object.makeActive (eval at 977 (0.9c8eff7….hot-update.js:71), <anonymous>:92:8)
    at Object.onTouchStart (eval at 977 (0.9c8eff7….hot-update.js:71), <anonymous>:82:10)
    at HTMLSpanElement.eventProxy (eval at <anonymous> (bundle.js:765), <anonymous>:96:32)

TappableMixin.js Uncaught TypeError this.setState is not a function

javascript – React this.setState is not a function – Stack Overflow

react-tappable Mixin  this.setState is not a function

【总结】

然后去把:

/node_modules/react-tappable/lib/TappableMixin.js

从:

    makeActive: function makeActive() {
        if (!this.isMounted()) return;
        this.clearActiveTimeout();
        this.setState({
            isActive: true
        });
    },

改为:

    makeActive: function makeActive() {
        if (!this.isMounted()) return;
        this.clearActiveTimeout();
        this.setState({
            isActive: true
        });
    }.bind(this),

至少解决了这个this.setState is not a function的问题。

转载请注明:在路上 » 【已解决】react-tappable中TappableMixin.js报错:Uncaught TypeError this.setState is not a function

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
96 queries in 0.229 seconds, using 20.16MB memory