I have the following hook and we use it to bind to channels.
import { useEffect, useState } from "react";
import { Channel, PresenceChannel } from "pusher-js";
import PrivateChannel from 'pusher-js/types/src/core/channels/private_channel';
import { usePusher } from "./usePusher";
export type ChannelType = PrivateChannel | PresenceChannel
function _useChannel<T extends ChannelType>(channelName: string) {
const pusher = usePusher()
const [channel, setChannel] = useState<T>();
useEffect(() => {
const pusherChannel = pusher.subscribe(channelName) as T;
setChannel(pusherChannel);
return () => pusher?.unsubscribe(channelName);
}, [channelName, pusher]);
return channel;
}
When I open the console, I see this message: Unexpected mix of '||' and '&&' no-mixed-operators
Why does this happen?