ably-js
ably-js copied to clipboard
Right way to clean up listeners
Hi
If I use React
useEffect(() => {
const connectionChangeCallback = (
connectionState: ConnectionStateChange,
) => {
...
};
client?.connection?.on(connectionChangeCallback);
return () => client?.connection?.off(connectionChangeCallback);
}, [client]);
Does that the right way to clean up that listener when the component unmounts?