折腾:
期间,去解决了:
【已解决】react-tappable中TappableMixin.js报错:Uncaught TypeError this.setState is not a function
但是:
用代码:
makeActive: function makeActive() { if (!this.isMounted()) return; this.clearActiveTimeout(); this.setState({ isActive: true }); }.bind(this), |
结果报错:
TappableMixin.js?81b1:90 Uncaught TypeError: this.isMounted is not a function at Object.makeActive (eval at 977 (0.6291309….hot-update.js:7), <anonymous>:90:13) at Object.onTouchStart (eval at 977 (0.6291309….hot-update.js:7), <anonymous>:82:10) at HTMLSpanElement.eventProxy (eval at <anonymous> (bundle.js:765), <anonymous>:96:32) |
this.isMounted is not a function
react-tappable this.isMounted is not a function
this.isMounted is not a function
ajax – this.IsMounted() is not a function – Stack Overflow
isMounted is an Antipattern – React Blog
react js long press
isMounted is deprecated · Issue #105 · JedWatson/react-tappable
-》
中写的是:已经在这个commit中解决了此问题了:
Fix `isMounted` deprecation · matthieuprat/react-tappable@5e583e1
但是看到其写法,和我刚才试的类似
componentWillUnmount: function componentWillUnmount() { this.isMounted = false; // this.mounted = false; // mounted = false; // this.setState({isMounted : false}); // this.state.isMounted = false; this.cleanupScrollDetection(); this.cancelPressDetection(); this.clearActiveTimeout(); // console.log(`componentWillUnmount this.state.isMounted=${this.state.isMounted}`); //}.bind(this), }, componentDidMount: function() { this.isMounted = true; }, // componentDidMount: function componentDidMount() { // // this.mounted = true; // mounted = true; // // this.setState({isMounted : true}); // // console.log(`componentDidMount this.isMounted=${this.isMounted}`); // // console.log(`makeActive this.state.isMounted=${this.state.isMounted}`); // // }.bind(this), // }, makeActive: function makeActive() { // if (!this.isMounted()) return; //if (!this.isMounted().bind(this)) return; // console.log(`makeActive this.state.isMounted=${this.state.isMounted}`); // if (!this.state.isMounted) return; // console.log(`makeActive this.mounted=${this.mounted}`); // console.log(`makeActive mounted=${mounted}`); // if (!this.mounted) return; // if (!mounted) return; console.log(`makeActive this.isMounted=${this.isMounted}`); if (!this.isMounted) return; this.clearActiveTimeout(); // clearActiveTimeout(); this.setState({ isActive: true }); // }.bind(this), }, |
-》但是虽然没有警告了,但是onPress感觉没有生效啊
-》我的函数handlePressEvent还是没有被调用啊。
转载请注明:在路上 » 【未解决】react-tappable中代码出错:this.isMounted is not a function