Last active
September 19, 2018 07:14
-
-
Save unicodeveloper/0db17ab39a2ab535012238aca1edf4e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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