Skip to content

Commit

Permalink
Chore: 소스 복구
Browse files Browse the repository at this point in the history
  • Loading branch information
y-solb committed Jul 7, 2024
1 parent 3ea8625 commit f4f600b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ export default async function Home() {
const queryClient = new QueryClient()
await queryClient.prefetchInfiniteQuery({
queryKey: ['portfolioList'],
queryFn: ({ pageParam }) => getPortfolioList(pageParam as number),
queryFn: ({ pageParam }) => getPortfolioList(pageParam),
initialPageParam: 1,
staleTime: 30 * 1000,
})
const dehydratedState = dehydrate(queryClient)
return (
Expand Down
17 changes: 9 additions & 8 deletions src/containers/main/RecentPortfolioList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@

import PortfolioList from '@/components/portfolio/PortfolioList'
import { useInfinitePortfolioQuery } from '@/hooks/queries/portfolio'
// import useInfiniteScroll from '@/hooks/useInfiniteScroll'
import useInfiniteScroll from '@/hooks/useInfiniteScroll'
import { useMemo, useRef } from 'react'

function RecentPortfolioList() {
const { data, isFetchingNextPage } = useInfinitePortfolioQuery()
const { data, hasNextPage, fetchNextPage, isFetchingNextPage } =
useInfinitePortfolioQuery()

const portfolios = useMemo(() => {
return [...(data?.pages?.flatMap((page) => page.data) || [])]
}, [data])

// const fetchMorePortfolio = () => {
// if (!isFetchingNextPage && hasNextPage) {
// fetchNextPage()
// }
// }
const fetchMorePortfolio = () => {
if (!isFetchingNextPage && hasNextPage) {
fetchNextPage()
}
}
const loaderRef = useRef<HTMLDivElement>(null)

// useInfiniteScroll(loaderRef, fetchMorePortfolio)
useInfiniteScroll(loaderRef, fetchMorePortfolio)

return (
<PortfolioList
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/queries/portfolio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ import {
export const useInfinitePortfolioQuery = () => {
return useInfiniteQuery({
queryKey: ['portfolioList'],
queryFn: ({ pageParam }) => getPortfolioList(pageParam as number),
queryFn: ({ pageParam }) => getPortfolioList(pageParam),
getNextPageParam: (lastPage) => {
const {
meta: { currentPage, hasNextPage },
} = lastPage
return hasNextPage ? currentPage + 1 : undefined
},
initialPageParam: 1,
staleTime: 30 * 1000,
staleTime: 60 * 1000,
})
}

export const useInfiniteLikePortfolioQuery = () => {
return useInfiniteQuery({
queryKey: ['likePortfolioList'],
queryFn: ({ pageParam }) => getLikePortfolioList(pageParam as number),
queryFn: ({ pageParam }) => getLikePortfolioList(pageParam),
getNextPageParam: (lastPage) => {
const {
meta: { currentPage, hasNextPage },
Expand Down

0 comments on commit f4f600b

Please sign in to comment.