[캠퍼스] 신규 공지사항 표시 hydration mismatch 수정#1105
Merged
Conversation
D0Dam
reviewed
Jan 6, 2026
Contributor
D0Dam
left a comment
There was a problem hiding this comment.
오랜만에 들렸다 갑니당
next는 type import가 혹시 안되나요?
그런거라면 type prefix 관련 리뷰들은 무시해주세용
Comment on lines
+23
to
+25
| export function isArticleWithNew(article: Article | ArticleWithNew): article is ArticleWithNew { | ||
| return 'isNew' in article && typeof (article as ArticleWithNew).isNew === 'boolean'; | ||
| } |
| } | ||
|
|
||
| export default function ArticleHeader({ boardId, title, registeredAt, author, hit }: ArticleHeaderProps) { | ||
| export default function ArticleHeader({ boardId, title, registeredAt, author, hit, isNew }: ArticleHeaderProps) { |
Contributor
Author
| import Image from 'next/image'; | ||
| import Link from 'next/link'; | ||
| import { Article } from 'api/articles/entity'; | ||
| import { Article, ArticleWithNew, isArticleWithNew } from 'api/articles/entity'; |
Contributor
There was a problem hiding this comment.
Suggested change
| import { Article, ArticleWithNew, isArticleWithNew } from 'api/articles/entity'; | |
| import { type Article, type ArticleWithNew, isArticleWithNew } from 'api/articles/entity'; |
| @@ -1,6 +1,7 @@ | |||
| import { keepPreviousData, useQuery } from '@tanstack/react-query'; | |||
| import { PaginationInfo } from 'api/articles/entity'; | |||
| import { ArticleWithNew, PaginationInfo } from 'api/articles/entity'; | |||
Contributor
There was a problem hiding this comment.
Suggested change
| import { ArticleWithNew, PaginationInfo } from 'api/articles/entity'; | |
| import type { ArticleWithNew, PaginationInfo } from 'api/articles/entity'; |
|
|
||
| function setArticleRegisteredDate(time: string) { | ||
| const registered = convertDate(time) | ||
| export const isNewArticle = (registeredAt: string, currentDate: Date): boolean => { |
| <span className={styles['list__item-type']}>{convertArticlesTag(article.board_id)}</span> | ||
| <span className={styles['list__item-title']}>{article.title}</span> | ||
| {setArticleRegisteredDate(article.registered_at) && ( | ||
| {isArticleWithNew(article) && article.isNew && ( |
Contributor
There was a problem hiding this comment.
무언가 두 개의 성격이 같아 보이는데, 로직 상 어쩌다 이렇게 나오게 되었나요?
Contributor
Author
There was a problem hiding this comment.
초기에는 ArticleList가 Article 타입을 받을 수 있어 isArticleWithNew type guard가 필요했으나, 이후 useArticles 훅에서 select를 통해 항상 ArticleWithNew를 반환하도록 변경되었습니다. 하지만 기존 type guard를 제거하지 않아 불필요한 중복 체크가 남아있었고, 이번 수정으로 타입 정의와 로직을 정리했습니다.
IndexArticles에서도 위 내용을 그대로 가져다 쓰면서 중복 체크가 되고 있었기에 수정 진행했습니다!
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

What is this PR? 🔍
Changes 📝
Precaution
사용자의 이용에 문제가 되는 버그는 아니라고 생각하여 핫픽스가 아닌 일반 버그 수정으로 올렸습니다.
✔️ Please check if the PR fulfills these requirements
developbranch unconditionally?main?yarn lint