Switch routes, the timer on the previous page is still running

at the home page, the message prompts you to jump to the Detail component to initialize the data that can only be rendered from Control. Clicking on a new message here will not trigger constructor, so I am dealing with nextProps data. If the time of the first question is not over, the two countdown times of the second question will be running, and the time will be reduced at double speed.
I have cleared the timer wherever I can think of, but there is still a problem. Ask for help


you called init in both componentWillReceiveProps and componenetDidMount , but did not clear the timer at the beginning of init . Therefore, in the case of url = nowurl , the timer is created again, and the timer created for the first time (from componentDidMount ) is not cleared, thus causing two timers to run at the same time


if it is a build, you can clear the timer for this page before the page is destroyed

Menu