Skip to content

Commit

Permalink
feat: SearchPost 페이지에 infinite scroll 훅 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
ienrum committed Jul 10, 2024
1 parent 55447e6 commit 2258d33
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/app/(post)/search/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,22 @@ import ChipContainer, {
} from '@/src/app/_components/ChipContainer';
import PostItem from '@/src/app/_components/PostItem';
import EmptyPage from '@/src/components/EmptyPage';
import useInfiniteScroll from '@/src/hooks/useInfiniteScroll';

import TopBar from '../../../components/Topbar';
import SearchBar from './_components/SearchBar';

const SearchPostPage = () => {
const searchParams = useSearchParams();
const channel = (searchParams.get('channel') as ChannelType | null) ?? 'all';

const [keyword, setKeyword] = useState('');
const { content: posts } = useGetPostListAPI(keyword, CATEGORY_MAP[channel]);
const { data: posts, fetchNextPage } = useGetPostListAPI(
keyword,
CATEGORY_MAP[channel],
);

const scrollRef = useInfiniteScroll(fetchNextPage);

const handleRemoveClick = () => {
setKeyword('');
Expand Down Expand Up @@ -53,6 +60,7 @@ const SearchPostPage = () => {
) : (
<EmptyPage href='/createPost' text='작성 글이 없습니다.' />
)}
<div ref={scrollRef} />
</main>
</>
)}
Expand Down

0 comments on commit 2258d33

Please sign in to comment.