Timer, delay page disappears

Mar.11,2021

judgment condition


setState there is a process to change the value of a variable, which is not performed by Synchronize. Just the number of seconds of a timer, there is no need to put it in the state. Or you can cache the number of seconds (that is, how many seconds it takes) in componentDidMount and modify it directly based on this cache variable. For example,

let {countDown} = this.state;

//...
-countDown;
Menu