Timer Jump page
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
Copy the code
The reason is that after the component is mounted, the timer is set and the setState operation is performed in the callback. When you switch routes, the component has been unloaded, and the asynchronous operation callback is still operating, so setState does not get a value.
Memory leak problem, solution:
componentWillUnmount() {
this.setState = (state,callback)=>{
return;
};
}
Copy the code