plugins/smedjen/skills/react-patterns/SKILL.md
React hooks, context, composition, performance optimization, and common anti-patterns. Covers when to use each hook, composition over inheritance, performance decision tree, and state management choices.
npx skillsauth add hjemmesidekongen/ai react-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Components sharing implicit state via context: <Select>, <Select.Option>, <Select.Trigger>. Parent provides state through context; children consume without prop drilling. Use React.createContext internally — never expose the context. Export only the compound pieces.
The as prop renders a component as any element type: <Button as="a" href="/home">. Type with <T extends React.ElementType> + React.ComponentPropsWithoutRef<T>. Use for design system primitives (Box, Text, Button). Avoid on complex components — type complexity compounds.
Separate logic from rendering: a hook (useCombobox) manages state, keyboard navigation, and ARIA; a render component consumes the hook's return values. Callers own the markup. Return prop-getter functions (getInputProps, getMenuProps) that attach handlers and ARIA attributes to arbitrary elements.
Server Component (default): data fetching, database access, heavy imports, no interactivity needed. Client Component ('use client'): interactive UI, browser APIs, hooks, effects. Push 'use client' to the lowest possible boundary.
Composition rule: server components can render client components. Client components cannot import server components — but can accept them as children props.
use(): read promises and context in render. Suspends until resolved. Works inside conditionals — unlike hooks, doesn't follow hook rules.
Actions: functions passed to action prop on <form>. Async, server or client. Replaces onSubmit + preventDefault + fetch.
useActionState(action, initialState): tracks pending state, return value, and error for form actions. Replaces useState + useTransition + manual error handling.
useOptimistic(state, updateFn): instant UI updates before server confirmation. Reverts automatically on action failure.
useMemouseCallbackReact.lazy + SuspenseSee references/process.md for composition examples, state management decisions, and anti-patterns.
development
Creates a brand from scratch through market research and interactive sparring. Runs competitive research via Perplexity, then guides the user through positioning, audience, voice, values, and content pillars. Produces the full brand guideline set at .ai/brand/{name}/. Use when building a new brand, defining brand strategy for a product, or when /våbenskjold:create is invoked.
testing
Loads brand guidelines from .ai/brand/{name}/ and makes them available to the current context. Progressive disclosure: L1 confirms brand exists, L2 loads summary, L3 loads specific files on demand. Use when a downstream skill or user needs brand context, or when /våbenskjold:apply is invoked.
documentation
Guided reinvention of an existing brand guideline. Loads current brand from .ai/brand/{name}/, identifies what to keep vs change, and walks the user through targeted evolution. Preserves brand equity while updating positioning, voice, or values. Use when refreshing a brand or when /våbenskjold:evolve is invoked.
development
Codifies an existing brand from materials, samples, and references. Analyzes provided content to extract voice patterns, values, and positioning. Produces the same guideline format as brand-strategy. Use when a brand already exists but isn't documented, or when /våbenskjold:audit is invoked.