AB
Size: a a a
AB
X
DN
useEffect(() => {
const observer = new IntersectionObserver(
([entry]) => {
if (entry.isIntersecting) {
console.log(entry)
dispatch(fetchData(paginationOptions.usersPerPage, paginationOptions.currentPage));
dispatch(setCurrentPage());
console.log('It works!',paginationOptions.currentPage )
}
},
{
root: null,
rootMargin: "0px",
threshold: 0.1
}
);
if (ref.current) {
observer.observe(ref.current);
}
return () => { observer.unobserve(ref.current) }
}, [ paginationOptions.currentPage]);
AB
VK
V
VK
X
useEffect(() => {
const observer = new IntersectionObserver(
([entry]) => {
if (entry.isIntersecting) {
console.log(entry)
dispatch(fetchData(paginationOptions.usersPerPage, paginationOptions.currentPage));
dispatch(setCurrentPage());
console.log('It works!',paginationOptions.currentPage )
}
},
{
root: null,
rootMargin: "0px",
threshold: 0.1
}
);
if (ref.current) {
observer.observe(ref.current);
}
return () => { observer.unobserve(ref.current) }
}, [ paginationOptions.currentPage]);
IntersectionObserver
. Если это обычный Observable, то там точно не нужно создавать каждый раз новый.V
VK
V
VK
V
V
VK
V
VK
V
VK
V