examples/with-infinite-pagination/README.md
This example shows how to implement infinite scroll pagination with urql
in your React UI code.
It's slightly different than the with-pagination example
and shows how to implement a full infinitely scrolling list with only your UI code,
while fulfilling the following requirements:
with-graphcache-pagination,
the urql cache doesn't have to know about your infinite list, and this works
with any cache, even the document cachewith-pagination, your list can use cursors,
and each page can update, while keeping the variables for the next page dynamic.In other words, unless you need a flat array of items
(e.g. unless you’re using React Native’s FlatList), this is the simplest way
to implement an infinitely scrolling, paginated list.
This example is also reapplicable to other libraries, like Svelte or Vue.
To run this example install dependencies and run the start script:
yarn install
yarn run start
# or
npm install
npm run start
This example contains:
urql bindings and a React app with a client set up in src/App.js
src/SearchResults.jsx
SearchRoot component loads the first page of results and renders SearchPageSearchPage displays cached results, and otherwise only starts a network request on
a button pressPackage component is used for each result item