小ネタ。 API オプション – SWRによるとrefreshIntervalオプションに0より大きい値を設定するとsetIntervalのような定期的なポーリングリクエストを実装できる。 // 5秒おきにfetcherでリクエストを送る const { data } = useSWR(key, fetcher, {refreshInterval: 5000}) const [isProcessing, setIsProcessing] = useState(true) const { data, error } = useSWR(key, fetcher, { refreshInterval: isProcessing ? 5000 : 0, onSuccess: ({ status }) = > { setIsProcessing(status === 'processing') }