Files
magnus919_agent-skills/frontend-engineering/references/state-management.md
T
Magnus HedemarkandGitHub c7c4d3b74f Port 11 methodology skills from hermes-profiles (#69)
Engineering: backend-engineering, frontend-engineering, data-engineering,
ml-engineering, platform-engineering, qa-methodology

Executive: go-to-market, legal-strategy, operational-design, org-design,
product-strategy

ml-engineering: added missing training-infrastructure.md reference
qa-methodology: added test-data-management, performance-testing,
security-testing references

All frontmatter converted to agent-skills convention.
Source: https://github.com/magnus919/hermes-profiles
2026-07-21 00:58:26 -04:00

1.8 KiB

State Management

State Classification

State type Where it lives How to manage Example
Local UI state Component useState, useReducer Form input values, toggle open/closed
Shared UI state Context or store useContext, Zustand, Redux Theme preference, sidebar collapsed state
Server state Cache layer React Query, SWR, Apollo User profile, product list, search results
URL state Browser URL useRouter, search params Current page, sort order, active filters
Form state Form library React Hook Form, Formik Form values, validation errors, submission status

Data Fetching Patterns

Pattern When to use Loading Error Empty
Fetch on render Data needed immediately on page load Skeleton/spinner Error toast or inline error Empty state message
Fetch on interaction Data needed after user action Button loading state Inline error next to trigger Handle in response
Prefetch Next likely interaction Background fetch, no loading UI Silent failure, retry on explicit action Handle on navigation
Infinite scroll Paginated lists Loading indicator at bottom Inline error with retry "No more results"
Optimistic update Actions with predictable success Instant UI update, rollback on error Revert optimistic update, show error toast N/A

Caching Strategy

Aspect Approach
Cache duration Configurable per query type (stale-while-revalidate)
Invalidation On mutation success, optimistic update, or manual refetch
Deduplication Identical in-flight queries share a single request
Garbage collection Unused cache entries evicted after configurable TTL