Skip to content

bugfix:#260 컴포넌트가 마운트된 이후에 렌더링하도록 설정#262

Merged
hye410 merged 1 commit intodevfrom
Bugfix/#260-main-link-bug
Apr 30, 2025
Merged

bugfix:#260 컴포넌트가 마운트된 이후에 렌더링하도록 설정#262
hye410 merged 1 commit intodevfrom
Bugfix/#260-main-link-bug

Conversation

@hye410
Copy link
Copy Markdown
Collaborator

@hye410 hye410 commented Apr 30, 2025

💡 관련이슈

#260

🍀 작업 요약

-메인 페이지 -> 온보딩 페이지 이동 시 link 한 번만 클릭해도 바로 이동되도록 수정

💬 에러 원인

  • 부모 컴포넌트인 서버 컴포넌트에서는 처음에 디바이스 타입을 알 수 없음
  • useDeviceType hook내부의 getDeviceType함수에 의해 초기값은 null
  • if (!device) return <LoadingAnimation />; 조건문이 충족되어 로직이 실행되지만 서버컴포넌트에서 LoadingAnimation 사용불가
  • 결론 : hydration 오류 발생

🙌 해결

  • 로딩 UI 대신 빈 태그를 초기에 렌더링
  • 메인 페이지를 그릴 수 있는 클라이언트 컴포넌트가 완전이 렌더링되고 난 이후에 device 타입에 따라 알맞은 컴포넌트가 렌더링 되도록 수정

✔️ 이슈 닫기

Closes #260
Ref #이슈번호 // 해당 이슈에 대한 작업이 완전히 끝나지 않은 경우

Summary by CodeRabbit

  • 변경 사항
    • 홈 화면에서 초기 마운트 시 로딩 애니메이션이 더 이상 표시되지 않으며, 컴포넌트가 마운트된 후에만 화면이 렌더링됩니다.

@hye410 hye410 added 🐞 BugFix Something isn't working 🚨 ASAP 즉시 처리해야 하는 가장 긴급한 작업으로, 최고 우선순위를 가집니다. 즉각적인 반응이 필요한 중요한 상황입니다. 💎다혜 labels Apr 30, 2025
@hye410 hye410 self-assigned this Apr 30, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2025

Walkthrough

이 변경사항은 RenderHome 컴포넌트의 마운트 타이밍을 제어하기 위해 로컬 상태 변수 isMounted를 도입합니다. 컴포넌트가 마운트된 후에만 렌더링이 진행되도록 하여, 기존에 device 값이 없을 때 표시되던 로딩 애니메이션 대신 마운트 전에는 아무것도 렌더링하지 않습니다. 이로써 최초 진입 시 불필요한 렌더링을 방지하고, 마운트 이후에만 홈 화면이 정상적으로 표시되도록 변경되었습니다.

Changes

파일/경로 변경 요약
src/features/home/render-home.tsx isMounted 상태 및 useEffect 도입, 마운트 전 빈 fragment 반환, 로딩 애니메이션 제거

Assessment against linked issues

Objective Addressed Explanation
메인페이지에서 온보딩 페이지로 한 번에 네비게이팅 되어야 함 (#260)

Suggested reviewers

  • ImJaeOne
  • choichangyeon
  • parkminjo

Poem

🐰
컴포넌트가 살짝 숨죽인 채,
마운트될 때까지 기다리네.
로딩 애니는 안녕, 깔끔한 시작,
한 번의 클릭으로 네비게이션 착착!
토끼도 좋아할 이 변화,
홈이 더 빠르게 열려라!
🌱

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/features/home/render-home.tsx (1)

6-7: 사용하지 않는 불필요한 import 제거 필요

LoadingAnimation 컴포넌트가 더 이상 사용되지 않습니다. 코드 가독성과 번들 사이즈 최적화를 위해 불필요한 import 문을 제거하는 것이 좋습니다.

import MobileHome from './mobile-home';
-import LoadingAnimation from '@/components/common/loading-animation';
import { useEffect, useState } from 'react';
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ac764a and bd0ef23.

📒 Files selected for processing (1)
  • src/features/home/render-home.tsx (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/features/home/render-home.tsx (1)
src/hooks/customs/use-device-type.ts (2)
  • DEVICE (4-8)
  • useDeviceType (25-36)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (3)
src/features/home/render-home.tsx (3)

10-14: 클라이언트 측 마운트 로직 구현이 적절합니다

isMounted 상태와 useEffect를 사용하여 클라이언트 측 마운트를 처리하는 접근 방식이 적절합니다. 이는 서버 사이드 렌더링 시 hydration 에러를 방지하는 표준 패턴입니다.


16-16: 빈 프래그먼트 렌더링으로 hydration 에러 해결

마운트되기 전까지 빈 프래그먼트를 렌더링하는 방식은 PR 목표에 맞게 hydration 에러를 방지합니다. 이전에 로딩 애니메이션을 사용했을 때 발생한 문제를 효과적으로 해결합니다.

이 접근 방식의 한 가지 단점은 초기 렌더링 시 화면이 잠시 비어 있을 수 있다는 점입니다. 그러나 이는 hydration 에러 방지와 싱글 클릭 네비게이션을 위해 필요한 트레이드오프입니다.


25-27: 기본값으로 DesktopHome 사용

device가 여전히 null이거나 정의된 유형과 일치하지 않는 경우 DesktopHome을 기본값으로 사용하는 것이 적절합니다. 이는 기기 유형 감지에 실패하더라도 사용자에게 기본 UI를 제공합니다.

Copy link
Copy Markdown
Collaborator

@ImJaeOne ImJaeOne left a comment

Choose a reason for hiding this comment

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

금방 해결하셨네요 고생하셨습니다!

parkminjo

This comment was marked as off-topic.

Copy link
Copy Markdown
Collaborator

@parkminjo parkminjo left a comment

Choose a reason for hiding this comment

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

고생 많으셨습니다!

Copy link
Copy Markdown
Collaborator

@choichangyeon choichangyeon left a comment

Choose a reason for hiding this comment

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

승인합니다!

@hye410 hye410 merged commit e087362 into dev Apr 30, 2025
2 checks passed
@hye410 hye410 deleted the Bugfix/#260-main-link-bug branch April 30, 2025 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 BugFix Something isn't working 💎다혜 🚨 ASAP 즉시 처리해야 하는 가장 긴급한 작업으로, 최고 우선순위를 가집니다. 즉각적인 반응이 필요한 중요한 상황입니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bugfix] 메인 페이지 한 번에 네비게이팅 안 되는 오류

4 participants