B
B
BorisNaumov2020-09-03 07:40:18
Socket.io
BorisNaumov, 2020-09-03 07:40:18

Do I need to unsubscribe from the socket from the react when componentWillUnmount?

Tell me, please, is it necessary to unsubscribe from the socket from the react when componentWillUnmount, if subscribed in the same component in componentDidMount? If you do not unsubscribe, will memory be clogged with garbage on each transition along the route, which the garbage collector on the server with the node cannot clean up?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Suntsev, 2020-09-03
@GreyCrew

Look in the browser in the network-> ws tab.
How much it clogs up, if every time you enter the component a new instance of the socket connection is created, then of course you need to cut it down.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question