Skip to content
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

메인페이지 리팩토링 #323

Merged
merged 3 commits into from
Aug 3, 2024
Merged

Conversation

bomi8489
Copy link
Contributor

@bomi8489 bomi8489 commented Aug 1, 2024

📑 이슈 번호

#321 #310

🚧 구현 내용

메인페이지에 Suspense를 적용하였습니다.

기존 메인 페이지에서는 useGetPopularLinks로 불러와지는 links의 존재여부에 따라서 메인화면의 모든 구성요소들의 렌더링이 결정되었습니다. 즉, links가 늦게 fetch될수록 렌더링이 지연된다는 문제점을 가지고 있었습니다.

// 기존의 코드
function Home() {
  const { links, isPopularLinksLoading } = useGetPopularLinks();
  /*
  ...
  */

  return isPopularLinksLoading ? (
    <Spinner />
  ) : (/*...*/)

이를 개선하고자 Suspense 도입을 시도하였고, 다음과 같은 과정에 걸쳐 리팩토링 하였습니다.

  1. links 데이터가 필요한 LinkItem에 대한 코드 모듈화
  2. Suspense 적용
  3. 동적 모듈 import를 하기위해 next/dynamic을 사용 및 Suspense 제거(dynamicReact.lazySuspense의 기능이 합쳐졌기 때문)

인기링크리스트메인스페이스리스트에 스켈레톤UI를 적용하였습니다.

SkeletonUI

이전의 스켈레톤UI를 삭제했던 이유인 CLS 이슈를 해결하였습니다.

image

🚨 특이 사항

메인페이지의 렌더링 여부가 useGetPopularLinks에 종속적이라 렌더링 지연이 생기는 것일 거라 가정하고 수정하였지만 렌더링지연은 개선되지 않았습니다.

@bomi8489 bomi8489 added the 🔨 Refactor 리팩토링 label Aug 1, 2024
@bomi8489 bomi8489 self-assigned this Aug 1, 2024
@bomi8489 bomi8489 merged commit 70a2c6e into develop Aug 3, 2024
1 check passed
@bomi8489 bomi8489 deleted the feat/#321/refactoring-main branch August 3, 2024 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 Refactor 리팩토링
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant