Cleanup observers

And name function to avoid commenting.
This commit is contained in:
Franck Royer 2021-07-15 14:09:58 +10:00
parent 6e22897f74
commit a8e2b908ba
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 4 additions and 3 deletions

View File

@ -107,7 +107,9 @@ export default function App() {
waku.relay.addObserver(handleRelayMessage, [ChatContentTopic]);
return;
return function cleanUp() {
waku?.relay.deleteObserver(handleRelayMessage, [ChatContentTopic]);
};
}, [waku]);
useEffect(() => {
@ -140,8 +142,7 @@ export default function App() {
handleProtocolChange.bind({}, waku)
);
// To clean up listener when component unmounts
return () => {
return function cleanUp() {
waku?.libp2p.peerStore.removeListener(
'change:protocols',
handleProtocolChange.bind({}, waku)