Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useCallback } from 'react';
import { useSuspenseQuery } from '@tanstack/react-query';
import { useNavigate } from 'react-router-dom';

Expand All @@ -15,37 +16,27 @@ import { StatusType } from '@shared/types/type.ts';

import * as styles from './recommended-info-section.css.ts';

interface recommendedInfoSectionProps {
interface StaticContentProps {
userName?: string;
productName?: string;
company?: string;
keywordChips?: string[];
}

/** 보험 추천받은 유저가 볼 화면 */
export const RecommendedInfoSection = ({
const StaticContent = ({
Comment on lines +18 to +25
Copy link
Member

@jogpfls jogpfls Dec 29, 2025

Choose a reason for hiding this comment

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

따로 이 컴포넌트들을 파일로 분리 안하신 이유가 있나요?!

Copy link
Member Author

Choose a reason for hiding this comment

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

파일 분리를 고민하다가, 재사용 목적이 아니고 분산시킬 필요성이 우리 눈에 깔끔한 거라면 불필요하다고 생각했어요.
StaticContent, BottomButton 이 이 파일에서만 쓰이는 로컬 UI 이기 때문에 같은 파일에 두어서 지역성을 유지하는 게 낫다고 생각했는데, 요 부분은 코드리뷰에서 논의해보고 싶었어요. 혜린님은 분리하는 게 좋다고 생각하시나요!

userName,
}: recommendedInfoSectionProps) => {
const navigate = useNavigate();
const handleNavigateReport = () => {
navigate(routePath.REPORT);
};

const { data: reportSummary } = useSuspenseQuery(
HOME_QUERY_OPTIONS.REPORT_SUMMARY(),
);
const targetToIconMap = new Map(
homeCardConfig.map(({ target, icon }) => [target, icon]),
);

if (!reportSummary) {
return;
}

productName,
company,
keywordChips,
}: StaticContentProps) => {
return (
<section className={styles.infoSection}>
<>
<img
src={'./3Dicon_background.webp'}
width={223}
height={185}
className={styles.backgroundLogo}
alt=""
/>
<div className={styles.titleSection}>
<InsuranceSubtitle
Expand All @@ -58,11 +49,11 @@ export const RecommendedInfoSection = ({
<InsuranceTitle
fontColor={'white'}
fontStyle={'eb_28'}
name={reportSummary.productName}
company={reportSummary.company}
name={productName}
company={company}
/>
<div className={styles.chipList}>
{reportSummary.keywordChips?.map((chip, index) => (
{keywordChips?.map((chip, index) => (
<Chip
key={index}
variant="round"
Expand All @@ -74,7 +65,58 @@ export const RecommendedInfoSection = ({
))}
</div>
</div>
</>
);
};

interface BottomButtonProps {
onClick: () => void;
}

const BottomButton = ({ onClick }: BottomButtonProps) => {
return (
<div className={styles.bottomButton}>
<TextButton color={'white'} size="sm" onClick={onClick}>
<p>구체적인 내용 확인하기</p>
<Icon name={'caret_right_md'} color="white" />
</TextButton>
</div>
);
};

interface recommendedInfoSectionProps {
userName?: string;
}

/** 보험 추천받은 유저가 볼 화면 */
export const RecommendedInfoSection = ({
userName,
}: recommendedInfoSectionProps) => {
const navigate = useNavigate();
const handleNavigateReport = useCallback(() => {
navigate(routePath.REPORT);
}, [navigate]);
Copy link
Member

Choose a reason for hiding this comment

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

이 부분에서 useCallback이 꼭 필요할까? 라는 의문이 들었어요!
현재 handleNavigateReport는 memoized 된 컴포넌트에 전달되지 않고 이 PR의 핵심 개선 포인트가 리렌더링 최적화가 아닌 repaint 범위 분리에 있는 만큼 단순 함수로 구현해도 동작 및 성능 측면에서 문제는 없을 것 같아 보여욥!

Copy link
Member Author

Choose a reason for hiding this comment

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

동의합니다 반영했습니다 👍🏻


const { data: reportSummary } = useSuspenseQuery(
HOME_QUERY_OPTIONS.REPORT_SUMMARY(),
);

const targetToIconMap = new Map(
homeCardConfig.map(({ target, icon }) => [target, icon]),
);

if (!reportSummary) {
return;
}

return (
<section className={styles.infoSection}>
<StaticContent
userName={userName}
productName={reportSummary.productName}
company={reportSummary.company}
keywordChips={reportSummary.keywordChips}
/>
<Carousel slidesPerView={4.5} autoPlay className={styles.homeCardList}>
{reportSummary.statuses?.map((card, index) => (
<Carousel.Item key={index}>
Expand All @@ -92,13 +134,7 @@ export const RecommendedInfoSection = ({
</Carousel.Item>
))}
</Carousel>

<div className={styles.bottomButton}>
<TextButton color={'white'} size="sm" onClick={handleNavigateReport}>
<p>구체적인 내용 확인하기</p>
<Icon name={'caret_right_md'} color="white" />
</TextButton>
</div>
<BottomButton onClick={handleNavigateReport} />
</section>
);
};
Loading