Skip to content

Conversation

@jjanie00
Copy link
Collaborator

요구사항

기본

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

심화

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

스크린샷

주요 변경사항

  • app router 로 진행했습니다.

멘토에게

  • 키워드 검색 시, 데이터가 새로 페칭되기 전 화면이 잠깐 깜빡이는 현상이 발생합니다. 정확한 원인을 파악하지 못해서 함께 질문드립니다 !

withyj-codeit and others added 30 commits September 3, 2023 21:57
[Fix] delete merged branch github action
design: Header UI 구현 및 Pretend Font 설정 및 적용
- getAllArticles API 호출 방식 axios > fetch 로 변경
- feat: dropdown handler 클릭 시 메뉴 열림
- design: dropdown 기본 UI 작성
@jjanie00 jjanie00 requested a review from kiJu2 April 20, 2025 17:42
@jjanie00 jjanie00 self-assigned this Apr 20, 2025
@jjanie00 jjanie00 added the 매운맛🔥 뒤는 없습니다. 그냥 필터 없이 말해주세요. 책임은 제가 집니다. label Apr 20, 2025
@kiJu2
Copy link
Collaborator

kiJu2 commented Apr 22, 2025

스프리트 미션 하시느라 수고 많으셨어요.
학습에 도움 되실 수 있게 꼼꼼히 리뷰 하도록 해보겠습니다. 😊

@kiJu2
Copy link
Collaborator

kiJu2 commented Apr 23, 2025

키워드 검색 시, 데이터가 새로 페칭되기 전 화면이 잠깐 깜빡이는 현상이 발생합니다. 정확한 원인을 파악하지 못해서 함께 질문드립니다 !

오잉 로컬에서 확인해본 결과 딱히 블링크 되는 현상은 없는 것 같아요.
제가 시도한 것은 다음과 같습니다:

  • Network 속도 slow 4g로 변경
  • "냐옹" 검색 후 엔터
2025-04-23.1.56.02.mov

혹시 제가 놓친게 있다면 DM주세요 😊

Copy link
Collaborator

Choose a reason for hiding this comment

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

오호 vscode 세팅도 형상관리에 저장해두셨군요?

같은 팀원들이 같은 툴과 비슷한 환경으로 개발한다면 헙업에 도움 될 수 있지요 !


type SearchParams = Promise<{ [key: string]: string | string[] | undefined }>;

export default async function BoardsPage({ searchParams }: { searchParams: SearchParams }) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

굿굿~ 상단 페이지 컴포넌트에서 서버사이드로 fetch를 하고 있군요 !

이러한 구조는 서버 사이드에서 fetch를 하고 하위 컴포넌트로 데이터를 내려줘서 TTV를 줄일 수 있는 좋은 패턴이예요 !

Time To View(TTV): 사용자가 웹브라우저에서 내용을 볼 수 있는 시점

기존 리액트 때: 클라이언트가 서버에 요청 -> 클라이언트에 HTML을 전달 -> 서버에 데이터 요청 -> 데이터베이스 -> ...
현재 구조: 클라이언트가 서버에 요청 -> 서버가 데이터베이스에 데이터 요청 -> 클라이언트 반환 및 렌더링

간선도 훨씬 짧아졌습니다 👍👍

@@ -0,0 +1,128 @@
@import 'tailwindcss';

@theme {
Copy link
Collaborator

Choose a reason for hiding this comment

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

크으 새로운 라이브러리도 척척 이시군요 ! 👍👍

Comment on lines +11 to +14
export const metadata: Metadata = {
title: "Panda Market",
description: "Trading site for used goods",
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

메타 데이터 설정도 훌륭합니다 !

layout.tsx에서 정의할 수 있지요. 추 후 boards/:id 페이지가 개발 된다면 동적인 메타 데이터도 넣어볼 수 있겠네요 😊😊

Comment on lines +11 to +43
export const getArticles = async ({
page = 1,
pageSize = 10,
orderBy = 'recent',
keyword,
}: GetArticlesParams = {}): Promise<GetArticlesResponse> => {
// set query parameter
const params = new URLSearchParams();
params.append('page', page.toString());
params.append('pageSize', pageSize.toString());
params.append('orderBy', orderBy);
if (keyword) {
params.append('keyword', keyword);
}

// get baseURL
const baseURL = process.env.NEXT_PUBLIC_API_URL;
const res = await fetch(`${baseURL}/articles?${params.toString()}`, {
headers: {
'Content-Type': 'application/json',
},
next: {
revalidate: 3600,
},
});

if (!res.ok) {
throw new Error(`HTTP Error : ${res.status}`);
}

const data = await res.json();
return data;
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

오호 이 친구만 fetch를 사용해보셨군요.

nextjs의 .next를 활용해보고자 시범적으로 바꿔보신 것으로 보여요 ! 훌륭한 학습 자세예요 😊😊
테스트도 직접 해보시면서 유효한 시간 내에 서버 단에서 네트워크 요청을 안보내는지 확인도 해보시면 좋을 것 같네요 👍

Comment on lines +45 to +79
// post article
export const postArticle = async (data: ArticleBody) => {
const res = await apiClient.post<ArticleResponse>('/articles', data);
return res.data;
};

// get article by id
export const getArticleById = async (articleId: number) => {
const res = await apiClient.get<ArticleResponse>(`/articles/${articleId}`);
return res.data;
};

// patch article by id
export const patchArticleById = async (articleId: number, data: ArticleBody) => {
const res = await apiClient.patch<ArticleResponse>(`/articles/${articleId}`, data);
return res.data;
};

// delete article by id
export const deleteArticleById = async (articleId: number) => {
const res = await apiClient.delete<DeleteArticleResponse>(`/articles/${articleId}`);
return res.data;
};

// post like in article by id
export const postLikeInArticle = async (articleId: number) => {
const res = await apiClient.post<ArticleResponse>(`/articles/${articleId}/like`);
return res.data;
};

// delete like in article by id
export const deleteLikeInArticle = async (articleId: number) => {
const res = await apiClient.delete<ArticleResponse>(`/articles/${articleId}/like`);
return res.data;
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

깔-끔 합니다 👍

추가로, 만약 로깅을 해야한다면 try, catch를 해볼 수도 있겠네요 😊

@kiJu2
Copy link
Collaborator

kiJu2 commented Apr 23, 2025

수고하셨습니다 해명님 ! 잠시 쉬었음에도 불구하고 엄청난 속도의 학습력입니다 👍👍👍👍
이미 프로젝트를 시작하셨지만 분명 해명님은 팀에 영향력 있는 든든한 동료가 될 것임에 확신합니다 !

과제 하시느라 정말 수고 많으셨어요 해명님 !

@kiJu2 kiJu2 merged commit a45a8a2 into codeit-bootcamp-frontend:Next-장해명 Apr 23, 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.

4 participants