I know that we can bind pusher event like this
useEffect(() => {
var channel = pusher.subscribe('my-channel');
channel.bind('my-event', function(data) {
alert(JSON.stringify(data));
});
},[]);
But i can't find any ways to unbind it when the component unload. Is there some way to unbind it like this
useEffect(() => {
var channel = pusher.subscribe('my-channel');
channel.bind('my-event', function(data) {
alert(JSON.stringify(data));
});
return () => channel.unbind('my-event');
},[]);