Skip to content

Instantly share code, notes, and snippets.

@unicodeveloper
Last active September 19, 2018 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unicodeveloper/0db17ab39a2ab535012238aca1edf4e9 to your computer and use it in GitHub Desktop.
Save unicodeveloper/0db17ab39a2ab535012238aca1edf4e9 to your computer and use it in GitHub Desktop.
const FeedData = ({ match }) => (
<Query
query={FEED_QUERY}
variables={{
type: match.params.type.toUpperCase() || "TOP",
offset: 0,
limit: 10
}}
fetchPolicy="cache-and-network"
>
{({ loading, error, data, fetchMore, networkStatus }) => (
if (networkStatus === 3) return "Loading more items in a bit...";
<Feed
entries={data.feed || []}
onLoadMore={() =>
fetchMore({
variables: {
offset: data.feed.length
},
updateQuery: (prev, { fetchMoreResult }) => {
if (!fetchMoreResult) return prev;
return Object.assign({}, prev, {
feed: [...prev.feed, ...fetchMoreResult.feed]
});
}
})
}
/>
)}
</Query>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment