[WEB-1481] fix: multiple API calls in inbox issues on closed issues tab. (#4691)
* fix: multiple API calls on scroll and closed issues tab. * fix: pagination loader on initial load.
This commit is contained in:
parent
20acb0dd17
commit
77b73dc032
5 changed files with 38 additions and 39 deletions
|
|
@ -9,12 +9,12 @@ export type UseIntersectionObserverProps = {
|
|||
|
||||
export const useIntersectionObserver = (
|
||||
containerRef: RefObject<HTMLDivElement>,
|
||||
elementRef: RefObject<HTMLDivElement>,
|
||||
elementRef: HTMLDivElement | null,
|
||||
callback: () => void,
|
||||
rootMargin?: string
|
||||
) => {
|
||||
useEffect(() => {
|
||||
if (elementRef.current) {
|
||||
if (elementRef) {
|
||||
const observer = new IntersectionObserver(
|
||||
(entries) => {
|
||||
if (entries[entries.length - 1].isIntersecting) {
|
||||
|
|
@ -26,16 +26,16 @@ export const useIntersectionObserver = (
|
|||
rootMargin,
|
||||
}
|
||||
);
|
||||
observer.observe(elementRef.current);
|
||||
observer.observe(elementRef);
|
||||
return () => {
|
||||
if (elementRef.current) {
|
||||
if (elementRef) {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
observer.unobserve(elementRef.current);
|
||||
observer.unobserve(elementRef);
|
||||
}
|
||||
};
|
||||
}
|
||||
// while removing the current from the refs, the observer is not not working as expected
|
||||
// fix this eslint warning with caution
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [rootMargin, callback, elementRef.current, containerRef.current]);
|
||||
}, [rootMargin, callback, elementRef, containerRef.current]);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue