相关疑难解决方法(0)

Javascript setTimeout立即在React Native中运行

我的问题是setTimeout运行吗?about 5 seconds较早。例如,当我将其设置为时5 seconds,它将立即运行,但是当我在上时15 seconds,它将在10 seconds以后运行。

我什至调查了这个问题:React Native中的setTimeout,但是我仍然无法解决问题

changeNotify() {
    let that = this;
    console.log("before");
    setTimeout(function () {
        console.log("After");
        that.setState({notifyModal: false})
    }, 5000);
}
Run Code Online (Sandbox Code Playgroud)

并在渲染

<Button
   title='change'
   onPress={() => this.setState({notifyModal: true},()=>this.changeNotify())}
/>
Run Code Online (Sandbox Code Playgroud)

javascript settimeout react-native

7
推荐指数
1
解决办法
661
查看次数

标签 统计

javascript ×1

react-native ×1

settimeout ×1