When using socket.io-client in react, the this direction inside the switching compenent, will be changed. What is the cause?

when using socket.io-client in react, the this direction inside the switching compenent, will be changed. What is the cause?

my socket.on is registered in compnentDidMount, but it is not destroyed when the component is removed, and the this point inside the callback time is retained. I tried to assign this to that, at the top of the componentDidMount, but the that.setState still does not take effect

Mar.31,2021

can match socket to window , so it becomes global, and you can modify it at any time.
it is recommended that the value of onmessage of socket be placed in state of redux , not in the state of the component.
if you just use socket in the component, drop websocket close when componentWillUnmount .

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9b576-47611.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9b576-47611.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?