File size: 599 Bytes
d15f07c
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
import { useQuery } from '@tanstack/react-query'
import { fetchTopicUpcoming, type TopicUpcomingResponse } from '../api/topicUpcoming'

/** What is coming up on a topic (#1302): one cache entry shared by the story screen, its headline and the home card. */
export function useTopicUpcoming(topic: string, stateCode?: string | null, city?: string | null) {
  return useQuery<TopicUpcomingResponse>({
    queryKey: ['topic-upcoming', topic, stateCode ?? '', (stateCode && city) || ''],
    queryFn: () => fetchTopicUpcoming(topic, stateCode, city, 24),
    staleTime: 5 * 60_000,
    retry: 1,
  })
}