diff --git a/examples/infinite/pages/index.js b/examples/infinite/pages/index.js index 4f7378494..865b4d9b6 100644 --- a/examples/infinite/pages/index.js +++ b/examples/infinite/pages/index.js @@ -9,19 +9,16 @@ export default function App() { const [repo, setRepo] = useState('reactjs/react-a11y') const [val, setVal] = useState(repo) - const { data, error, mutate, size, setSize, isValidating } = useSWRInfinite( - (index) => - `https://api.github.com/repos/${repo}/issues?per_page=${PAGE_SIZE}&page=${ - index + 1 - }`, - fetch - ) + const { data, mutate, size, setSize, isValidating, isLoadingMore } = + useSWRInfinite( + index => + `https://api.github.com/repos/${repo}/issues?per_page=${PAGE_SIZE}&page=${ + index + 1 + }`, + fetch + ) const issues = data ? [].concat(...data) : [] - const isLoadingInitialData = !data && !error - const isLoadingMore = - isLoadingInitialData || - (size > 0 && data && typeof data[size - 1] === 'undefined') const isEmpty = data?.[0]?.length === 0 const isReachingEnd = isEmpty || (data && data[data.length - 1]?.length < PAGE_SIZE) @@ -31,7 +28,7 @@ export default function App() {
setVal(e.target.value)} + onChange={e => setVal(e.target.value)} placeholder="reactjs/react-a11y" />