diff --git a/src/features/Posts/Components/PostsList/PostsList.tsx b/src/features/Posts/Components/PostsList/PostsList.tsx index 383f97a..d983037 100644 --- a/src/features/Posts/Components/PostsList/PostsList.tsx +++ b/src/features/Posts/Components/PostsList/PostsList.tsx @@ -1,19 +1,14 @@ import { useCallback } from "react" import { Post } from "src/features/Posts/types" import { useReachedBottom } from "src/utils/hooks/useReachedBottom" -import { ListProps } from "src/utils/interfaces" +import { ListComponentProps } from "src/utils/interfaces" import PostCard, { PostCardSkeleton } from "../PostCard" -type Props = ListProps +type Props = ListComponentProps export default function PostsList(props: Props) { - - const reachedBottom = useCallback(() => { - console.log("NEW FETCH") - }, []) - - const { ref } = useReachedBottom(reachedBottom) + const { ref } = useReachedBottom(props.onReachedBottom) if (props.isLoading) return
diff --git a/src/features/Posts/pages/FeedPage/FeedPage.tsx b/src/features/Posts/pages/FeedPage/FeedPage.tsx index 81c2c89..c72d99d 100644 --- a/src/features/Posts/pages/FeedPage/FeedPage.tsx +++ b/src/features/Posts/pages/FeedPage/FeedPage.tsx @@ -1,15 +1,22 @@ import { useFeedQuery } from 'src/graphql' -import { MOCK_DATA } from 'src/mocks/data' +import { useInfiniteQuery } from 'src/utils/hooks' import PostsList from '../../Components/PostsList/PostsList' import TrendingCard from '../../Components/TrendingCard/TrendingCard' import PopularCategories from './PopularCategories/PopularCategories' import SortBy from './SortBy/SortBy' import styles from './styles.module.css' + export default function FeedPage() { - const feedQuery = useFeedQuery() + const feedQuery = useFeedQuery({ + variables: { + take: 10, + skip: 0 + } + }) + const { fetchMore, isFetchingMore } = useInfiniteQuery(feedQuery, 'getFeed') return (
- +