【发布时间】:2017-12-18 07:56:36
【问题描述】:
我正在学习 react-native,现在我被这个错误困在状态课上:
_this2.setState is not a function.
这是当前的代码块。
...
export default class StopWatch extends Component {
constructor(props){
super(props);
this.state = {
timeElapsed: null
}
}
handleStartStopClick(){
var startTime = new Date();
setInterval(() => {
this.setState(previousState => {
return {timeElapsed:new Date() - startTime};
});
}, 100);
}
...
我做错了什么?
【问题讨论】:
标签: reactjs react-native state