-
Notifications
You must be signed in to change notification settings - Fork 37
[김승석] Sprint9 #299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kich555
merged 9 commits into
codeit-bootcamp-frontend:Next-김승석
from
kss761036:Next-김승석-sprint9
Jan 20, 2025
The head ref may contain hidden characters: "Next-\uAE40\uC2B9\uC11D-sprint9"
Merged
[김승석] Sprint9 #299
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
592a3d9
feat: 베스트 게시물 기능 추가
c94f749
feat: 게시글 SSR로 작업
7c3cfc5
feat: 게시글 orderBy 기능 작업
498ba56
feat: 게시글 검색 기능 구현
32ae842
feat: 반응형 작업 완료
8d3017f
feat: 반응형 pagesize 작업 및 로딩중, 비어있음 적용
2f83b8f
feat: pagesize 무한스크롤 기능 및 useOutsideClick hook 추가
87d6588
fix: 네트리파이 배포 오류 수정
e8cb077
style: css파일 삭제 후 인라인속성으로 변경
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +1,37 @@ | ||
| import fetchBoardList from "@/lib/fetch-board-list"; | ||
| import { InferGetServerSidePropsType } from "next"; | ||
| import styles from "./board.module.css"; | ||
| import BoardBestList from "@/components/board-best-list"; | ||
| import BoardList from "@/components/board-list"; | ||
| import Link from "next/link"; | ||
| import { useState } from "react"; | ||
| import { useEffect, useState } from "react"; | ||
| import { Article } from "../../../types"; | ||
|
|
||
| export const getServerSideProps = async () => { | ||
| const list = await fetchBoardList(1, 3, "like"); | ||
| const commonList = await fetchBoardList(1, 10, "recent"); | ||
| return { | ||
| props: { | ||
| list, | ||
| commonList, | ||
| }, | ||
| }; | ||
| }; | ||
|
|
||
| export default function Page({ | ||
| list, | ||
| commonList, | ||
| }: InferGetServerSidePropsType<typeof getServerSideProps>) { | ||
| export default function Page() { | ||
| const [sortState, setSortState] = useState(false); | ||
| const [order, setOrder] = useState("recent"); | ||
| const [list, setList] = useState<Article[]>([]); | ||
| const [commonList, setCommonList] = useState<Article[]>([]); | ||
|
|
||
| const onSortToggle = () => { | ||
| setSortState(!sortState); | ||
| }; | ||
|
|
||
| const fetchData = async () => { | ||
| try { | ||
| const bestResponse = await fetchBoardList(1, 3, "like"); | ||
| const commonResponse = await fetchBoardList(1, 10, order); | ||
|
|
||
| setList(bestResponse); | ||
| setCommonList(commonResponse); | ||
| } catch (error) { | ||
| console.error("데이터 가져오기 실패:", error); | ||
| } | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| fetchData(); | ||
| }, [order]); | ||
|
|
||
| const sortChange = (state: string) => { | ||
| if (state !== order) { | ||
| setOrder(state); | ||
|
|
@@ -40,7 +44,7 @@ export default function Page({ | |
| <div className="common_title">베스트 게시글</div> | ||
| <ul className={styles.board_best}> | ||
| {list.length === 0 ? ( | ||
|
||
| <p>데이터가 없습니다.</p> | ||
| <p></p> | ||
| ) : ( | ||
| list.map((el) => <BoardBestList key={el.id} {...el} />) | ||
| )} | ||
|
|
@@ -81,7 +85,7 @@ export default function Page({ | |
|
|
||
| <ul className={styles.board_common}> | ||
| {commonList.length === 0 ? ( | ||
| <p>데이터가 없습니다.</p> | ||
| <p></p> | ||
| ) : ( | ||
| commonList.map((el) => <BoardList key={el.id} {...el} />) | ||
| )} | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이런식으로 작성하려면
fetchData를 useCallback으로 만들고 useEffect의 의존성 배열에 fetchData를 집어넣어야해요