perf(frontend): Optimize component rendering with React.memo and hooks - Sprint 3 Story 2
Add React.memo to display components and useCallback/useMemo for better performance. Changes: - Added React.memo to TaskCard component - Added React.memo to StoryCard component - Added React.memo to KanbanBoard component - Added React.memo to KanbanColumn component - Added useCallback to kanban page drag handlers (handleDragStart, handleDragEnd) - Added useCallback to epics page handlers (handleDelete, getStatusColor, getPriorityColor) - Added useMemo for expensive computations in dashboard page (stats, recentProjects sorting) - Added useMemo for total tasks calculation in KanbanBoard - Removed unused isConnected variable from kanban page Performance improvements: - Reduced unnecessary re-renders in Card components - Optimized list rendering performance with memoized callbacks - Improved filtering and sorting performance with useMemo - Better React DevTools Profiler metrics 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
||||
DragStartEvent,
|
||||
closestCorners,
|
||||
} from '@dnd-kit/core';
|
||||
import { useState, useMemo } from 'react';
|
||||
import { useState, useMemo, useCallback } from 'react';
|
||||
import { useProjectStories } from '@/lib/hooks/use-stories';
|
||||
import { useEpics } from '@/lib/hooks/use-epics';
|
||||
import { useChangeStoryStatus } from '@/lib/hooks/use-stories';
|
||||
@@ -43,7 +43,7 @@ export default function KanbanPage() {
|
||||
|
||||
// SignalR real-time updates
|
||||
const queryClient = useQueryClient();
|
||||
const { isConnected } = useSignalRConnection();
|
||||
useSignalRConnection(); // Establish connection
|
||||
const changeStatusMutation = useChangeStoryStatus();
|
||||
|
||||
// Subscribe to SignalR events for real-time updates
|
||||
@@ -83,12 +83,12 @@ export default function KanbanPage() {
|
||||
Done: stories.filter((s) => s.status === 'Done'),
|
||||
}), [stories]);
|
||||
|
||||
const handleDragStart = (event: DragStartEvent) => {
|
||||
const handleDragStart = useCallback((event: DragStartEvent) => {
|
||||
const story = stories.find((s) => s.id === event.active.id);
|
||||
setActiveStory(story || null);
|
||||
};
|
||||
}, [stories]);
|
||||
|
||||
const handleDragEnd = (event: DragEndEvent) => {
|
||||
const handleDragEnd = useCallback((event: DragEndEvent) => {
|
||||
const { active, over } = event;
|
||||
setActiveStory(null);
|
||||
|
||||
@@ -101,7 +101,7 @@ export default function KanbanPage() {
|
||||
logger.debug(`[Kanban] Changing story ${story.id} status to ${newStatus}`);
|
||||
changeStatusMutation.mutate({ id: story.id, status: newStatus });
|
||||
}
|
||||
};
|
||||
}, [stories, changeStatusMutation]);
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user