Reactive Dashboard Performance
Expert in building production-grade reactive dashboards that load in <100ms and have comprehensive test coverage.
Core Expertise
Performance Patterns (Linear, Vercel, Notion-grade)
Skeleton-First Loading
- Render skeleton immediately (0ms perceived load)
- Stream in data progressively
- Never show spinners for <200ms loads
Aggressive Caching
- React Query with staleTime: 5min, cacheTime: 30min
- Optimistic updates for mutations
- Prefetch on hover/mount
Code Splitting
- Route-based splitting (Next.js automatic)
- Component-level lazy() for heavy widgets
- Preload critical paths
Memoization Strategy
- useMemo for expensive computations
- React.memo for pure components
- useCallback for stable references
Testing Reactive Dashboards
Mock Strategy
- Mock at service boundary (React Query, analytics)
- Never mock UI components (test real DOM)
- Use MSW for API mocking when possible
Async Handling
// WRONG - races with React
render(<Dashboard />);
const element = screen.getByText('Welcome');
// RIGHT - waits for async resolution
render(<Dashboard />);
const element = await screen.findByText('Welcome');
Timeout Debugging
- Timeouts mean: missing mock, wrong query, or component not rendering
- Use screen.debug() to see actual DOM
- Check console for unmocked errors
Test Wrapper Pattern
const TestProviders = ({ children }) => (
<QueryClientProvider client={testQueryClient}>
<AuthProvider>
{children}
</AuthProvider>
</QueryClientProvider>
);
Real-World Examples
- Linear Dashboard: Skeleton → Stale data → Fresh data (perceived <50ms)
- Vercel Dashboard: Prefetch on nav hover, optimistic deploys
- Notion Pages: Infinite cache, local-first, sync in background
Diagnostic Protocol
Integration Test Timeouts
Check what's actually rendering
render(<Component />);
screen.debug(); // See actual DOM
Find unmocked dependencies
- Check console for "not a function" errors
- Look for network requests in test output
- Verify all contexts are provided
Fix async queries
- Use findBy* instead of getBy*
- Increase timeout if needed:
waitFor(() => {...}, { timeout: 3000 })
- Mock React Query properly
Simplify component tree
- Test widgets individually first
- Add full integration tests last
- Use data-testid for complex queries
Performance Optimization
Dashboard Load Budget
| Phase |
Target |
| Skeleton render |
0-16ms (1 frame) |
| First data paint |
<100ms |
| Full interactive |
<200ms |
| Lazy widgets |
<500ms |
React Query Config
const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 5 * 60 * 1000, // 5min
cacheTime: 30 * 60 * 1000, // 30min
refetchOnWindowFocus: false,
refetchOnMount: false,
retry: 1,
},
},
});
Skeleton Pattern
function Dashboard() {
const { data, isLoading } = useQuery('dashboard', fetchDashboard);
// Show skeleton immediately, no loading check
return (
<div>
{data ? <RealWidget data={data} /> : <SkeletonWidget />}
</div>
);
}
Common Pitfalls
- Spinners for fast loads - Use skeletons instead
- Unmemoized expensive computations - Wrap in useMemo
- Testing implementation details - Test user behavior
- Mocking too much - Mock at boundaries only
- Synchronous test expectations - Everything is async
When debugging test timeouts, ALWAYS start with screen.debug() to see what actually rendered.
1---2name: reactive-dashboard-performance-23description: Expert in building blazing-fast reactive dashboards with comprehensive testing. Masters React performance patterns, testing strategies for async components, and real-world patterns from Linear,4 Vercel, Notion.5allowed-tools:6- Read7- Write8- Edit9- Bash10- Grep11- Glob12version: 1.0.013triggers:14- dashboard performance15- slow tests16- reactive testing17- integration tests timeout18- dashboard optimization19metadata:20 source: https://skillmd.com/skills/curiositech/reactive-dashboard-performance-221 category: Frontend Development22 tags:23 - react24 - performance25 - testing26 - dashboard27 - optimization28 pairs-with:29 - skill: react-performance-optimizer30 reason: Dashboard performance depends on React memoization, virtualization, and state management31 - skill: admin-dashboard32 reason: Admin dashboards are the primary consumer of reactive dashboard performance patterns33 - skill: data-viz-202534 reason: Dashboard charts and graphs require performant data visualization rendering35---3637# Reactive Dashboard Performance3839Expert in building production-grade reactive dashboards that load in <100ms and have comprehensive test coverage.4041## Core Expertise4243### Performance Patterns (Linear, Vercel, Notion-grade)44451. **Skeleton-First Loading**46 - Render skeleton immediately (0ms perceived load)47 - Stream in data progressively48 - Never show spinners for <200ms loads49502. **Aggressive Caching**51 - React Query with staleTime: 5min, cacheTime: 30min52 - Optimistic updates for mutations53 - Prefetch on hover/mount54553. **Code Splitting**56 - Route-based splitting (Next.js automatic)57 - Component-level lazy() for heavy widgets58 - Preload critical paths59604. **Memoization Strategy**61 - useMemo for expensive computations62 - React.memo for pure components63 - useCallback for stable references6465### Testing Reactive Dashboards66671. **Mock Strategy**68 - Mock at service boundary (React Query, analytics)69 - Never mock UI components (test real DOM)70 - Use MSW for API mocking when possible71722. **Async Handling**73 ```typescript74 // WRONG - races with React75 render(<Dashboard />);76 const element = screen.getByText('Welcome');7778 // RIGHT - waits for async resolution79 render(<Dashboard />);80 const element = await screen.findByText('Welcome');81 ```82833. **Timeout Debugging**84 - Timeouts mean: missing mock, wrong query, or component not rendering85 - Use screen.debug() to see actual DOM86 - Check console for unmocked errors87884. **Test Wrapper Pattern**89 ```typescript90 const TestProviders = ({ children }) => (91 <QueryClientProvider client={testQueryClient}>92 <AuthProvider>93 {children}94 </AuthProvider>95 </QueryClientProvider>96 );97 ```9899### Real-World Examples100101- **Linear Dashboard**: Skeleton → Stale data → Fresh data (perceived <50ms)102- **Vercel Dashboard**: Prefetch on nav hover, optimistic deploys103- **Notion Pages**: Infinite cache, local-first, sync in background104105## Diagnostic Protocol106107### Integration Test Timeouts1081091. **Check what's actually rendering**110 ```typescript111 render(<Component />);112 screen.debug(); // See actual DOM113 ```1141152. **Find unmocked dependencies**116 - Check console for "not a function" errors117 - Look for network requests in test output118 - Verify all contexts are provided1191203. **Fix async queries**121 - Use findBy* instead of getBy*122 - Increase timeout if needed: `waitFor(() => {...}, { timeout: 3000 })`123 - Mock React Query properly1241254. **Simplify component tree**126 - Test widgets individually first127 - Add full integration tests last128 - Use data-testid for complex queries129130## Performance Optimization131132### Dashboard Load Budget133134| Phase | Target |135|-------|--------|136| Skeleton render | 0-16ms (1 frame) |137| First data paint | <100ms |138| Full interactive | <200ms |139| Lazy widgets | <500ms |140141### React Query Config142143```typescript144const queryClient = new QueryClient({145 defaultOptions: {146 queries: {147 staleTime: 5 * 60 * 1000, // 5min148 cacheTime: 30 * 60 * 1000, // 30min149 refetchOnWindowFocus: false,150 refetchOnMount: false,151 retry: 1,152 },153 },154});155```156157### Skeleton Pattern158159```typescript160function Dashboard() {161 const { data, isLoading } = useQuery('dashboard', fetchDashboard);162163 // Show skeleton immediately, no loading check164 return (165 <div>166 {data ? <RealWidget data={data} /> : <SkeletonWidget />}167 </div>168 );169}170```171172## Common Pitfalls1731741. **Spinners for fast loads** - Use skeletons instead1752. **Unmemoized expensive computations** - Wrap in useMemo1763. **Testing implementation details** - Test user behavior1774. **Mocking too much** - Mock at boundaries only1785. **Synchronous test expectations** - Everything is async179180When debugging test timeouts, ALWAYS start with `screen.debug()` to see what actually rendered.