-
Notifications
You must be signed in to change notification settings - Fork 1
⚡ Bolt: [성능 개선] NetworkGraph 컴포넌트 렌더링 최적화 #1484
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| 'use client'; | ||
|
|
||
| import { useEffect, useId, useMemo, useRef, useState } from 'react'; | ||
| import { useEffect, useId, useMemo, useRef, useState, memo } from 'react'; | ||
| import { Network } from 'vis-network'; | ||
|
|
||
| interface Node { | ||
|
|
@@ -157,7 +157,9 @@ function describeEdge(edge: Edge, nodeMap: Map<string | number, string>) { | |
|
|
||
| import { apiClient } from '@/lib/api-client'; | ||
|
|
||
| export default function NetworkGraph() { | ||
| // ⚡ Bolt: Wrapped in React.memo() to prevent expensive re-instantiations of the vis-network DOM graph | ||
| // when parent dashboard components re-render. | ||
| export default memo(function NetworkGraph() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win Add or update a regression test before merging. This production change changes whether As per coding guidelines, TDD is expected: add or update tests before production code changes. 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| const containerRef = useRef<HTMLDivElement>(null); | ||
| const networkRef = useRef<Network | null>(null); | ||
| const unavailableRelationshipDescriptionId = useId(); | ||
|
|
@@ -478,4 +480,4 @@ export default function NetworkGraph() { | |
| /> | ||
| </div> | ||
| ); | ||
| } | ||
| }); | ||
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.
📝 Info: Performance benefit is overstated
Parent renders already preserve every graph-effect dependency, so they do not recreate vis-network.
memoonly avoids the component’s React render work.Was this helpful? React with 👍 or 👎 to provide feedback.