Javascript setTimeout立即在React Native中运行 [英] Javascript setTimeout Immediately runs in React Native
本文介绍了Javascript setTimeout立即在React Native中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的问题是setTimeout早先运行约5秒
。
例如,当我将其设置为 5秒
时,它立即运行,但当我在 15秒$ c时$ c>,它将在
10秒
之后运行。
My problem is that setTimeout runs about 5 seconds
earlier.
For example, when I set it to 5 seconds
, it runs immediately, but when I am on the 15 seconds
, it will run for about 10 seconds
later.
我甚至调查了这个问题: React Native中的setTimeout ,但我仍然无法解决问题
I even surveyed this question: setTimeout in React Native, but I still could not solve the problem
changeNotify() {
let that = this;
console.log("before");
setTimeout(function () {
console.log("After");
that.setState({notifyModal: false})
}, 5000);
}
并且在渲染中
<Button
title='change'
onPress={() => this.setState({notifyModal: true},()=>this.changeNotify())}
/>
推荐答案
这篇关于Javascript setTimeout立即在React Native中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文