Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- html
- sup태그
- focus 의사클래스
- iframe
- width속성
- br 태그
- 인접 형제 결합자
- id 선택자
- html 태그
- go live
- html tag i
- tag html
- RGBA
- i 태그
- 자식결합자
- sub태그
- padding 속성
- 아두이노
- Live Server
- not 의사클래스
- 임베디드
- RGB
- css
- 전체 선택자
- Checked 의사 클래스
- reveal in file explorer
- background-color 속성
- iframe 태그
- height속성
- 일반 형제 결합자
Archives
- Today
- Total
so woon!
[REACT QUERY] useQuery 의 refetch interval 기능 본문
학습일 : 2023. 04. 12
useQuery의 세번째 argument로 refetch interval을 줄 수가 있다.
<Chart.tsx>
function Chart({ coinId }: ChartProps) {
const { isLoading, data } = useQuery<IHistorical[]>(
["ohlcv", coinId],
() => fetchCoinHistory(coinId),
{
refetchInterval: 10000, // 10000ms = 10초마다 refetch
}
);
<Coin.tsx>
const { isLoading: tickersLoading, data: tickersData } = useQuery<PriceData>(
["tickers", coinId],
() => fetchCoinTickers(coinId!),
{
refetchInterval: 5000, // 5000ms = 5초마다 refetch
}
);
이렇게 작성을 해주면 작성해준 시간마다 refetch가 된다.
즉 바뀐 값이 실시간으로 변경되는 것을 볼 수 있다.
'React Query > 개념정리' 카테고리의 다른 글
[REACT QUERY] React Query 3 (0) | 2023.04.11 |
---|---|
[REACT QUERY] React Query 2 (0) | 2023.04.10 |
[REACT QUERY] React Query 1 (0) | 2023.04.10 |
Comments