Hi actually i want to load more data while i reach end of the flatlist , i tryed many thinks but still not able to complete is perfectly
here is my code to call API in first time
const { loading, error, data, fetchMore } = useQuery(
CollegeCardQueryTesting, {
variables: {
offset: 0,
limit: 3,
}
}
)
the array starts from data?.college
and here is the code for the load more functionality
onEndReached={async () => {
await fetchMore({
variables: { offSet: 5 },
updateQuery: (previousResult, { fetchMoreResult }) => {
console.log(previousResult);
// Don't do anything if there weren't any new items
if (!fetchMoreResult || fetchMoreResult.length === 0) {
return previousResult;
}
//Concating the new data with previous Data
ConcatedData = previousResult?.College?.concat(fetchMoreResult?.College);
console.log(ConcatedData);
return {
data: ConcatedData
};
},
});
}}
, please focus on it and give me the solution of these problem