From a8e2b908bacbd2ef3bc0abe5e64389256b8bcc5f Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 15 Jul 2021 14:09:58 +1000 Subject: [PATCH] Cleanup observers And name function to avoid commenting. --- examples/web-chat/src/App.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/web-chat/src/App.tsx b/examples/web-chat/src/App.tsx index f713f4b094..3de857af56 100644 --- a/examples/web-chat/src/App.tsx +++ b/examples/web-chat/src/App.tsx @@ -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)