A comprehensive guide to the loading, error, and empty states that make or break React UIs. The core insight is simple but constantly violated: only show loading spinners when you have no data, otherwise you get those annoying flashes on refetch. It walks through the full decision tree for each state, covers the error handling hierarchy from inline validation to full error screens, and hammers home the critical rule of always disabling buttons during async operations. The patterns are opinionated in a good way, with clear examples of what's wrong and what's right. If you've ever shipped a form that could be double-submitted or swallowed an error silently, this will fix your habits.

skills.sh installs
529
GitHub stars
33.2K
last updated
Aug 21, 2026

Install

$ npx -y skills add davila7/claude-code-templates --skill react-ui-patterns --agent claude-code

Installs into .claude/skills of the current project.

Files

React UI Patterns

Core Principles

  1. Never show stale UI - Loading spinners only when actually loading
  2. Always surface errors - Users must know when something fails
  3. Optimistic updates - Make the UI feel instant
  4. Progressive disclosure - Show content as it becomes available
  5. Graceful degradation - Partial data is better than no data

Loading State Patterns

The Golden Rule

Show loading indicator ONLY when there's no data to display.

// CORRECT - Only show loading when no data exists
const { data, loading, error } = useGetItemsQuery();

if (error) return <ErrorState error={error} onRetry={refetch} />;
if (loading && !data) return <LoadingState />;
if (!data?.items.length) return <EmptyState />;

return <ItemList items={data.items} />;
// WRONG - Shows spinner even when we have cached data
if (loading) return <LoadingState />; // Flashes on refetch!

Loading State Decision Tree

Is there an error?
  → Yes: Show error state with retry option
  → No: Continue

Is it loading AND we have no data?
  → Yes: Show loading indicator (spinner/skeleton)
  → No: Continue

Sponsors

Details

Repository
github.com/davila7/claude-code-templates
Categories
Frontend Development, Debugging
First seen
Jun 3, 2026

More from davila7/claude-code-templates

All 618
1sergiodxa avatarfrontend-react-router-best-practicessergiodxa/agent-skillsReact Router performance and architecture patterns. Use when writing loaders, actions, forms, routes, or working with React Router data fetching. Triggers on ta402skills.sh installs
2martinholovsky avatarvue-nuxtmartinholovsky/claude-skills-generatorVue 3 and Nuxt 3 for JARVIS AI Assistant UI development with security-first patterns227skills.sh installs
3oguzhan18 avatarangular-pwaoguzhan18/angular-ecosystem-skillsALWAYS use when working with Angular PWA, service workers, offline support, manifest, or web app installation in Angular applications.190skills.sh installs
4oguzhan18 avatarangular-ssroguzhan18/angular-ecosystem-skillsALWAYS use when working with Angular SSR, server-side rendering, hydration, prerendering, or Angular Universal in Angular applications.168skills.sh installs
5syncfusion avatarsyncfusion-react-rich-text-editorsyncfusion/react-ui-components-skillsImplements the Syncfusion React Rich Text Editor (RichTextEditorComponent) from ej2-react-richtexteditor, supporting HTML (WYSIWYG) and Markdown editing. Use th783skills.sh installs
6syncfusion avatarsyncfusion-react-themessyncfusion/react-ui-components-skillsUse this skill when users need to apply themes, customize appearance, switch dark mode, use CSS variables, configure icons, or modify visual styling for Syncfus755skills.sh installs