В моем приложении для машинописи NextJS / React я использую setTimeout.
В приложениях React есть ошибка, вызывающая мгновенный вызов setTimeout, и я нашел исправление в этом ответе здесь: ReactJS: setTimeout () не работает?
Ниже приведен мой код, но я получаю следующую ошибку при наборе this
на this.resetNotification
any 'this' неявно имеет тип 'any', потому что у него нет типа annotation.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
);
}