Integrated React-query in Gallery for handling api calling #264

Merged
pramod.mahajan merged 2 commits from query-Gallary into react-query-v2 2025-07-18 09:58:51 +00:00
Showing only changes of commit 89085d5069 - Show all commits

View File

@ -108,23 +108,26 @@ const ImageGallery = () => {
useEffect(() => {
if (!loaderRef.current) return;
const obs = new IntersectionObserver(
const observer = new IntersectionObserver(
([entry]) => {
if (
entry.isIntersecting &&
hasNextPage &&
!isFetchingNextPage &&
!isLoading
) {
if (entry.isIntersecting && hasNextPage && !isFetchingNextPage && !isLoading) {
fetchNextPage();
}
},
{ rootMargin: "200px", threshold: 0.1 }
);
obs.observe(loaderRef.current);
return () => obs.unobserve(loaderRef.current);
observer.observe(loaderRef.current);
return () => {
if (loaderRef.current) {
observer.unobserve(loaderRef.current);
}
};
}, [hasNextPage, isFetchingNextPage, isLoading, fetchNextPage]);
// Utility: derive filter options
const getUniqueValues = useCallback(
(idKey, nameKey) => {