在我的NextJS / React打字稿应用程序中,我正在使用setTimeout。
React应用程序中存在一个错误,导致setTimeout立即被调用,然后我在这里的答案中找到了解决方法:ReactJS:setTimeout()不起作用?
下面是我的代码,但我发现在以下打字稿错误this
的this.resetNotification
任何'this'隐式地具有'any'类型,因为它没有类型批注。ts(2683)Board.tsx(158,7):此容器遮盖了'this'的外部值。
@bind
resetNotification(): any {
console.log('resetNotification...');
this.setState({ notificationClass: 'spin-in-notification' });
this.props.setNotification('', false);
}
@bind
private handleNotificationClick() {
this.setState({ notificationClass: 'slide-out-bck-top' });
setTimeout(
function() {
this.resetNotification();
}
.bind(this),
500
);
}
使用setTimeout上的箭头功能针对此日期的父母道具进行操作
setTimeout(
() => {
this.resetNotification();
}......
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句