Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@
## 2024-05-24 - [React Component Memoization]
**Learning:** In React components like `WorkspaceHome`, when layout state or polling changes trigger parent re-renders, expensive child components like `EmailDetail` will also re-render unnecessarily if not memoized.
**Action:** Always consider `React.memo` for heavy child components that rely on stable props (like IDs) when the parent component has frequent unrelated state updates.
## 2024-05-24 - Memoizing heavy visualization components
**Learning:** Heavy visualization components that instantiate complex third-party DOM-manipulating libraries (e.g., `NetworkGraph` using `vis-network`) must be wrapped in `React.memo` to prevent costly re-instantiation and layout thrashing performance bottlenecks when parent components (like layout wrappers or dashboards) frequently re-render.
**Action:** Use `React.memo` for DOM-heavy visualization components that receive simple props and do not need to re-render upon unrelated layout state updates.
7 changes: 4 additions & 3 deletions frontend/src/components/NetworkGraph.tsx
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 {
Expand Down Expand Up @@ -157,7 +157,8 @@ function describeEdge(edge: Edge, nodeMap: Map<string | number, string>) {

import { apiClient } from '@/lib/api-client';

export default function NetworkGraph() {
// ⚡ Bolt: Wrapped heavy vis-network visualization in React.memo to prevent costly re-instantiation and layout thrashing
export default memo(function NetworkGraph() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 Info: Visualization lifecycle remains state-driven

memo cannot hide caller updates because the component accepts no props. Internal graph state still triggers rendering and the existing visualization lifecycle.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

const containerRef = useRef<HTMLDivElement>(null);
const networkRef = useRef<Network | null>(null);
const unavailableRelationshipDescriptionId = useId();
Expand Down Expand Up @@ -478,4 +479,4 @@ export default function NetworkGraph() {
/>
</div>
);
}
});
Loading