Warning: Can‘t perform a React state update on an unmounted component.

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 a useEffect cleanup function.

insert image description here

reason

This situation occurs: there are two components of A and B, the asynchronous function of the A component has not been executed, the A component has been unloaded, and then the B component is rendered. Can't perform a React state update on mentioned in the
prompt an unmounted component. Because the A component has been unmounted, the rendering in the asynchronous function is invalid

solution

The first one is not to load the A component,
and the second one is to render the B component after the A component is rendered

おすすめ

転載: blog.csdn.net/weixin_43614065/article/details/124313629