Fix infinite scroll
This commit is contained in:
parent
1957de483c
commit
6e436c7ee4
6
src/cache/index.ts
vendored
6
src/cache/index.ts
vendored
@ -26,9 +26,9 @@ const getPhotosCacheTags = (options: GetPhotosOptions = {}) => {
|
||||
} = options;
|
||||
|
||||
if (sortBy !== undefined) { tags.push(`sortBy-${sortBy}`); }
|
||||
if (limit !== undefined) { tags.push(`limit-${sortBy}`); }
|
||||
if (offset !== undefined) { tags.push(`offset-${sortBy}`); }
|
||||
if (tag !== undefined) { tags.push(`tag-${sortBy}`); }
|
||||
if (limit !== undefined) { tags.push(`limit-${limit}`); }
|
||||
if (offset !== undefined) { tags.push(`offset-${offset}`); }
|
||||
if (tag !== undefined) { tags.push(`tag-${tag}`); }
|
||||
// eslint-disable-next-line max-len
|
||||
if (takenBefore !== undefined) { tags.push(`takenBefore-${takenBefore.toISOString()}`); }
|
||||
// eslint-disable-next-line max-len
|
||||
|
||||
@ -31,7 +31,11 @@ export default function MorePhotos({
|
||||
|
||||
useEffect(() => {
|
||||
const observer = new IntersectionObserver(e => {
|
||||
if (triggerOnView && e[0].isIntersecting) {
|
||||
if (
|
||||
triggerOnView &&
|
||||
e[0].isIntersecting &&
|
||||
!isPending
|
||||
) {
|
||||
advance();
|
||||
}
|
||||
}, {
|
||||
@ -42,7 +46,7 @@ export default function MorePhotos({
|
||||
observer.observe(buttonRef.current!);
|
||||
|
||||
return () => observer.disconnect();
|
||||
}, [triggerOnView, advance]);
|
||||
}, [triggerOnView, advance, isPending]);
|
||||
|
||||
return (
|
||||
<button
|
||||
|
||||
Loading…
Reference in New Issue
Block a user