Skip to content

Instantly share code, notes, and snippets.

Avatar
🐝
Undefined

Juan Je García juangl

🐝
Undefined
View GitHub Profile
View use-infinite-fetch.ts
import React, { useCallback } from 'react';
type FetchReducerActions<DataT> =
| { type: 'REQUEST_START' }
| { type: 'REQUEST_SUCCESS'; payload: DataT }
| { type: 'REQUEST_ERROR'; error: Error }
| { type: 'FETCH_NEXT_PAGE' }
// use to fetch again after an error
| { type: 'RETRY' };