React js中Socket io触发事件两次

问题描述 投票:0回答:1

我面临一个问题。我的套接字 io 在客户端触发两次。我不知道这里有什么问题。 这是 src/socket.ts 文件中我的套接字配置代码 enter image description here

以及mainlayout文件中的socket连接 enter image description here

reactjs sockets websocket socket.io
1个回答
0
投票

到底是什么触发了两次?您能提供相关日志吗?

另外,我想知道这是否与启用 StrictMode 有关?

© www.soinside.com 2019 - 2024. All rights reserved.