Skip to content

Conversation

@kss761036
Copy link
Collaborator

요구사항

기본

  • 자유 게시판 페이지 주소는 “/boards” 입니다.
  • 전체 게시글에서 드롭 다운으로 “최신 순” 또는 “좋아요 순”을 선택해서 정렬을 할 수 있습니다.
  • 게시글 목록 조회 api를 사용하여 베스트 게시글, 게시글을 구현합니다.
  • 게시글 title에 검색어가 일부 포함되면 검색이 됩니다.

심화

  • 반응형으로 보여지는 베스트 게시판 개수를 다르게 설정할때 서버에 보내는 pageSize값을 적절하게 설정합니다.
  • next의 data prefetch 기능을 사용해봅니다.

멘토에게

@kss761036 kss761036 requested a review from kich555 January 18, 2025 22:32
@kss761036 kss761036 added the 순한맛🐑 마음이 많이 여립니다.. label Jan 18, 2025
? console.log("모바일")
: isTa && isMount
? console.log("타블렛")
: console.log("피씨");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

모바일 사이즈 적용 후 새로고침 하면
콘솔에 피씨가 잠깐 적용되는데 이유가 뭘까요,,

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useEffect는 초기 렌더링이 이미 시작된 이후에 실행되는 훅입니다.

때문에 원하는 결과를 도출하려면 useEffect() 아래에

if (!isMount) {
  return null; 
}

을 두어 초기 렌더링 중일 때 아무 것도 렌더링하지 않게 해야합니다

Copy link
Collaborator

@kich555 kich555 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다 ㅎㅎ

Comment on lines 6 to 13
export const getServerSideProps = async () => {
const list = await fetchBoardList(1, 3, "like");
return {
props: {
list,
},
};
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getServerSideProps 같은거 써보시는것도 좋습니다 ㅎ

Comment on lines 19 to 22
const date = new Date(dateString);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dayjs()같은 라이브러리를 사용하는게 좀더 편리할거에요

<>
<div className="common_title">베스트 게시글</div>
<ul className={styles.board_best}>
{list.length === 0 ? (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lodash같은 라이브러리를 사용해보는건 어떤가요?

Comment on lines 10 to 11
const list = await fetchBoardList(1, 3, "like");
const commonList = await fetchBoardList(1, 10, "recent");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이런식으로 코드를 작성하면 waterfall이 발생할 것 같아요 Promise.all을 활용해보는건 어떤가요?

Comment on lines 19 to 33
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]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이런식으로 작성하려면 fetchData를 useCallback으로 만들고 useEffect의 의존성 배열에 fetchData를 집어넣어야해요

Comment on lines 44 to 52
const onSearch: React.ChangeEventHandler<HTMLInputElement> = (e) => {
setSearch(e.target.value);
};

const onSearchEnter: React.KeyboardEventHandler<HTMLInputElement> = (e) => {
if (e.key === "Enter") {
setKeyword(search);
}
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

form과 submit이벤트를 활용하는게 더 시멘틱 해 보이네요

@kich555 kich555 merged commit 6899c93 into codeit-bootcamp-frontend:Next-김승석 Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

순한맛🐑 마음이 많이 여립니다..

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants