-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: 메인페이지 리랜더링 최적화 #82
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { memo } from "react"; | ||
|
|
||
| import NewsCarousel from "@/app/main/_components/news-carousel"; | ||
| import SearchStock from "@/app/main/_components/search-stock"; | ||
| import StockIndexCarousel from "@/app/main/_components/stock-carousel"; | ||
| import ErrorBoundary from "@/components/common/error-boundary"; | ||
|
|
||
| import { Fluctuation, News, StockData, TradingVolume } from "../types"; | ||
| import RankingSection from "./ranking-section"; | ||
|
|
||
| interface MainContentProps { | ||
| initialStockData: StockData; | ||
| initialNews: News[]; | ||
| traddata: TradingVolume[]; | ||
| flucdata: Fluctuation[]; | ||
| } | ||
|
|
||
| function MainContent({ | ||
| initialStockData, | ||
| initialNews, | ||
| traddata, | ||
| flucdata, | ||
| }: MainContentProps) { | ||
| return ( | ||
| <div className="flex flex-1 flex-col p-10 pt-30 md:px-32 lg:max-w-[calc(100%-320px)]"> | ||
| <ErrorBoundary errorMessage="검색 기능을 일시적으로 사용할 수 없습니다"> | ||
| <SearchStock /> | ||
| </ErrorBoundary> | ||
|
|
||
| <ErrorBoundary errorMessage="주가 정보를 불러올 수 없습니다"> | ||
| <StockIndexCarousel initialData={initialStockData} /> | ||
| </ErrorBoundary> | ||
|
|
||
| <RankingSection traddata={traddata} flucdata={flucdata} /> | ||
|
|
||
| <ErrorBoundary errorMessage="뉴스를 불러올 수 없습니다"> | ||
| <NewsCarousel initialData={initialNews} /> | ||
| </ErrorBoundary> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default memo(MainContent); | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { memo } from "react"; | ||
|
|
||
| import AssetInfo from "@/app/main/_components/asset-info"; | ||
| import MyStockInfo from "@/app/main/_components/stock-info"; | ||
| import ErrorBoundary from "@/components/common/error-boundary"; | ||
|
|
||
| function Sidebar() { | ||
| return ( | ||
| <div className="w-330 shrink-0"> | ||
| <div className="sticky top-24 flex flex-col gap-16"> | ||
| <ErrorBoundary errorMessage="자산 정보를 불러올 수 없습니다"> | ||
| <AssetInfo /> | ||
| </ErrorBoundary> | ||
| <ErrorBoundary errorMessage="관심 종목을 불러올 수 없습니다"> | ||
| <MyStockInfo /> | ||
| </ErrorBoundary> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default memo(Sidebar); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| "use client"; | ||
|
|
||
| import { memo } from "react"; | ||
|
|
||
| import FluctuationTable from "@/app/main/_components/flucctuate-table"; | ||
| import RankingStock from "@/app/main/_components/ranking-stock"; | ||
| import ErrorBoundary from "@/components/common/error-boundary"; | ||
|
|
||
| import { Fluctuation, TradingVolume } from "../types"; | ||
|
|
||
| interface RankingSectionProps { | ||
| traddata: TradingVolume[]; | ||
| flucdata: Fluctuation[]; | ||
| } | ||
|
|
||
| function RankingSection({ traddata, flucdata }: RankingSectionProps) { | ||
| return ( | ||
| <div className="mb-30 flex flex-col gap-20"> | ||
| <h2 className="mt-80 text-24-700">실시간 랭킹</h2> | ||
| <div className="flex w-full gap-30"> | ||
| <div className="mr-40 w-full"> | ||
| <ErrorBoundary errorMessage="거래량 순위를 불러올 수 없습니다"> | ||
| <RankingStock data={traddata} /> | ||
| </ErrorBoundary> | ||
| </div> | ||
| <div className="w-full"> | ||
| <ErrorBoundary errorMessage="변동폭 순위를 불러올 수 없습니다"> | ||
| <FluctuationTable data={flucdata} /> | ||
| </ErrorBoundary> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default memo(RankingSection); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| "use client"; | ||
|
|
||
| import { memo, PropsWithChildren } from "react"; | ||
|
|
||
| function TableWrapper({ children }: PropsWithChildren) { | ||
| return <div className="w-full">{children}</div>; | ||
| } | ||
|
|
||
| export default memo(TableWrapper); |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
🛠️ Refactor suggestion
성능 최적화 및 에러 처리 검토 결과
검토 결과 다음과 같은 사항들이 확인되었습니다:
개선이 필요한 부분:
SearchStock컴포넌트에 memo 적용StockIndexCarousel컴포넌트에 memo 적용NewsCarousel컴포넌트에 memo 적용🔗 Analysis chain
컴포넌트 최적화 및 에러 처리 개선 제안
컴포넌트 구현이 전반적으로 잘 되어있지만, 몇 가지 개선사항을 제안드립니다:
자식 컴포넌트들의 메모이제이션 상태를 확인해보겠습니다:
ErrorBoundary 개선 예시:
↓
Let me check the ErrorBoundary implementation to complete the verification:
Let me try a different approach to find the ErrorBoundary implementation:
Let me check the complete ErrorBoundary implementation:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 543
Script:
Length of output: 155
Script:
Length of output: 1110
Script:
Length of output: 1948