Skip to content

Commit

Permalink
fix: fix infinite articles scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
sashtje committed Oct 11, 2023
1 parent bf5b78a commit b5812dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/shared/lib/hooks/useInfiniteScroll/useInfiniteScroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { MutableRefObject, useEffect } from 'react';
export interface UseInfiniteScrollOptions {
callback?: () => void;
triggerRef: MutableRefObject<HTMLElement>;
wrapperRef: MutableRefObject<HTMLElement>;
wrapperRef?: MutableRefObject<HTMLElement>;
}

export function useInfiniteScroll({ callback, wrapperRef, triggerRef }: UseInfiniteScrollOptions) {
useEffect(() => {
let observer: IntersectionObserver | null = null;
const wrapperElement = wrapperRef.current;
const wrapperElement = wrapperRef?.current || null;
const triggerElement = triggerRef.current;

if (callback) {
Expand Down
6 changes: 5 additions & 1 deletion src/widgets/Page/ui/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ export const Page = memo((props: PageProps) => {

useInfiniteScroll({
callback: onScrollEnd,
wrapperRef,
wrapperRef: toggleFeatures({
name: 'isAppRedesigned',
on: () => undefined,
off: () => wrapperRef,
}),
triggerRef,
});

Expand Down

0 comments on commit b5812dc

Please sign in to comment.