add console logs to troubleshoot infinite scroll on production

This commit is contained in:
Sidney Alcantara
2022-05-30 13:00:19 +10:00
parent fe285711e1
commit d02fcfc037
3 changed files with 9 additions and 1 deletions

View File

@@ -76,6 +76,7 @@ export const tablePageAtom = atom(
(get, set, update: number | ((p: number) => number)) => {
// If loading more or doesnt have next page, dont request another page
const tableNextPage = get(tableNextPageAtom);
console.log("Next page requested", JSON.stringify(tableNextPage));
if (tableNextPage.loading || !tableNextPage.available) return;
const currentPage = get(tablePageAtom);

View File

@@ -170,7 +170,7 @@ export default function Table() {
const isAtBottom =
target.clientHeight + target.scrollTop >= target.scrollHeight - offset;
if (!isAtBottom) return;
console.log("Scroll");
console.log("Scrolled to bottom");
// Call for the next page
setTablePage((p) => p + 1);
},

View File

@@ -147,6 +147,7 @@ export function useFirestoreCollectionWithAtom<T = TableRow>(
// Set nextPageAtom if provided and getting the next page
else if (memoizedQuery.page > 0 && nextPageAtom) {
setNextPageAtom((s) => ({ ...s, loading: true }));
console.log("Loading next page", memoizedQuery.page);
}
// Create a listener for the query
@@ -170,6 +171,12 @@ export function useFirestoreCollectionWithAtom<T = TableRow>(
available: docs.length >= memoizedQuery.limit,
}));
}
console.log(
"Loaded next page",
memoizedQuery.page,
" Next page available:",
docs.length >= memoizedQuery.limit
);
} catch (error) {
if (onError) onError(error as FirestoreError);
else handleError(error);