1 import useSWR, { SWRConfiguration } from "swr"; 2 3 import { Channel } from "src/types"; 4 import { swrFetcher } from "src/utils/swr"; 5 6 const pollConfiguration: SWRConfiguration = { 7 refreshInterval: 3000, 8 }; 9 10 export function useChannels(poll = false) { 11 return useSWR<Channel[]>( 12 "/api/channels", 13 swrFetcher, 14 poll ? pollConfiguration : undefined 15 ); 16 } 17