V
V
Vlad Yanukovich2021-07-12 22:11:38
React
Vlad Yanukovich, 2021-07-12 22:11:38

Unmount component - what is it?

Hello ladies and gentlemen.

A question.

I am making an application using the API, pulling out all the necessary information from there, including images.

Everything works fine, however, sometimes, for some reason, the following happens with pictures. When updating a state (going through sections), sometimes I didn’t understand the pattern of the error, an error occurs that my pictures were not found (although everything was fine before that).

Then the second error appears immediately: 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.

To be honest, I did not quite understand how to fix this error. The only thing that helped was restarting the application.
If possible, explain what it is and how the problem can be solved.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Lewandowski, 2021-07-12
@Vladislav6

In useEffect or in some other way, you placed an event handler on something (element, store, etc.), the component was unmounted, but the handler remained.
UPD:
Actually, I will answer the title of the question. Unmount - the end of the component's life cycle, it was removed from the virtual DOM, to simplify.

A
Alice, 2021-07-13
@w3bsmes

I will supplement the answer Vladimir Lewandowski , the same thing, only briefly and clearly

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question