angelocolocado/clcd-agent-skills / skills/rrv7-mutation-ui-behavior
rrv7-mutation-ui-behavior
VerifiedUse this skill whenever wiring React Router v7 (RRv7) UI components, forms, modals, or action buttons to `clientAction` mutations—strictly governing pending/disabled button states, shadcn/ui `<Spinner />` usage, and response-driven UI updates (excluding visual design or styling).
RRv7 Mutation UI Behavior & State Rendering
Follow these strict rules whenever connecting a view or component to an RRv7 clientAction mutation. This skill governs functional UI behavior only—do not redesign layouts, colors, or unrelated styling.
Strict Implementation Rules
-
Mutation Wiring (
useFetcher/Form):- Connect forms or trigger buttons using RRv7's
useFetcher()(preferred for modals, inline actions, and multi-action pages) or<Form>withuseNavigation(). - Always include the matching
intentfield soclientActionroutes the request to the correct handler.
- Connect forms or trigger buttons using RRv7's
-
Disable Buttons During Pending State:
- Track the in-flight state (
fetcher.state !== "idle"ornavigation.state === "submitting"). - Strictly set
disabled={isSubmitting}on the primary submit button (and any secondary/cancel buttons that could conflict with the request) to prevent duplicate submissions.
- Track the in-flight state (
-
Loading Indicator (
<Spinner />from shadcn/ui):- Locate and import the project's shadcn/ui
<Spinner />component (typically in~/components/ui/spinneror@/components/ui/spinner). - Conditionally render
<Spinner />inside the active submit button while the mutation is pending (alongside descriptive loading text or replacing the button's static icon).
- Locate and import the project's shadcn/ui
-
Response Detection & Conditional UI Updates:
- Inspect the returned action payload (
fetcher.dataoruseActionData()) and explicitly handle the{ success, code, data }contract fromrrv7-api-mutation-handler: - On
success === true: Trigger the appropriate post-success UI state—such as resetting form fields, closing open dialogs/drawers/sheets, clearing temporary selection states, or displaying the updated state. - On
success === false: Keep the form or dialog open and preserve the user's current inputs. Ifcode === 422anddata?.errorsis present, display field-level validation error messages beneath the corresponding form inputs.
- Inspect the returned action payload (
-
Scope Boundary (Behavior Only, No Design Changes):
- Only add or modify state hooks,
disabledattributes,<Spinner />rendering, and conditional UI logic. - Preserve the component's existing layout, Tailwind classes, and visual design unless explicitly instructed otherwise.
- Only add or modify state hooks,
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |