|
@@ -450,7 +450,7 @@ export const DataProvider = (props: { children: React.ReactNode }) => {
|
|
// clear data
|
|
// clear data
|
|
setCollections([]);
|
|
setCollections([]);
|
|
// remove all listeners
|
|
// remove all listeners
|
|
- socket.current?.offAny();
|
|
|
|
|
|
+ socket.current?.off(WS_EVENTS.COLLECTION_UPDATE, updateCollections);
|
|
// listen to backend collection event
|
|
// listen to backend collection event
|
|
socket.current?.on(WS_EVENTS.COLLECTION_UPDATE, updateCollections);
|
|
socket.current?.on(WS_EVENTS.COLLECTION_UPDATE, updateCollections);
|
|
|
|
|
|
@@ -459,8 +459,7 @@ export const DataProvider = (props: { children: React.ReactNode }) => {
|
|
}
|
|
}
|
|
|
|
|
|
return () => {
|
|
return () => {
|
|
- // remove all listeners when component unmount
|
|
|
|
- socket.current?.offAny();
|
|
|
|
|
|
+ socket.current?.off(WS_EVENTS.COLLECTION_UPDATE, updateCollections);
|
|
};
|
|
};
|
|
}, [updateCollections, connected]);
|
|
}, [updateCollections, connected]);
|
|
|
|
|