From harness-claude
Declaratively handles async loading states with React Suspense boundaries for lazy-loaded components and Suspense-enabled data fetching.
How this skill is triggered — by the user, by Claude, or both
Slash command
/harness-claude:react-suspense-patternThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> Declaratively handle async loading states with React Suspense boundaries
Declaratively handle async loading states with React Suspense boundaries
React.lazy() — Suspense is requireduseEffect<Suspense fallback={<LoadingUI />}>.<ErrorBoundary> to handle promise rejections.React.lazy(() => import('./Component')).const HeavyChart = React.lazy(() => import('./HeavyChart'));
function Dashboard() {
return (
<ErrorBoundary fallback={<p>Failed to load chart</p>}>
<Suspense fallback={<ChartSkeleton />}>
<HeavyChart />
</Suspense>
</ErrorBoundary>
);
}
Suspense works by components "throwing" a promise when they are not ready. React catches the promise at the nearest Suspense boundary and renders the fallback until the promise resolves.
React 18 changes: startTransition lets you mark state updates as non-urgent, preventing Suspense fallbacks from showing for fast transitions (the previous content stays visible until the new content is ready).
Library support: Not all data-fetching approaches support Suspense. Use libraries that explicitly support it (useSuspenseQuery in React Query, use() hook in React 18+ with compatible data sources).
Common mistake: Placing the Suspense boundary too high (at the page level) shows a full-page spinner for small widget loads. Granular boundaries improve perceived performance.
https://patterns.dev/react/suspense-pattern
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeUses useSuspenseQuery to integrate React Suspense and error boundaries with TanStack Query, eliminating manual loading state conditionals.
Provides React UI patterns for loading states, error handling, and data fetching including skeletons, optimistic updates, decision trees, and error hierarchies. Use for async UI components.
Covers React 19 patterns: use() hook, Server Components, Actions, useActionState, useOptimistic, and component composition for modern React apps.