frontend-react
React 19 patterns: hooks, state, performance, components, testing.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- frontend-react
- author
- Joshua (joshlcoleman), Hermes Agent
- license
- MIT
- version
- 1.0.0
- metadata
- { "hermes": { "tags": [ "react", "frontend", "hooks", "state", "performance", "components" ], "related_skills": [ "nextjs", "design-ui", "testing" ] } }
- platforms
- [ "linux", "macos", "windows" ]
- description
- React 19 patterns: hooks, state, performance, components, testing.
02 资源文件 3
- 参考文档references/backends.md11.7 KB
- 参考文档references/constraints.md15.5 KB
- 参考文档references/examples.md19.6 KB
03 SKILL.md 正文
Frontend & React
When to Use
- Building React components or applications
- State management decisions
- Performance optimization
- Component architecture
Quick Reference
| Task | Approach |
|---|---|
| State | useState → useReducer → Zustand/Jotai (only when needed) |
| Data fetching | TanStack Query / SWR |
| Forms | React Hook Form + Zod |
| Styling | Tailwind CSS + cn() utility |
| Testing | Vitest + Testing Library |
| Icons | Lucide React |
React 19 Patterns
Server Components (RSC)
// Server Component (default in Next.js App Router)
async function UserProfile({ id }: { id: string }) {
const user = await db.user.findUnique({ where: { id } });
return <div>{user.name}</div>;
}
// Client Component (interactive parts)
'use client';
function LikeButton({ postId }: { postId: string }) {
const [liked, setLiked] = useState(false);
return <button onClick={() => setLiked(!liked)}>{liked ? '❤️' : '?'}</button>;
}
Custom Hooks Pattern
// ✅ Good: Encapsulates logic, reusable
function useDebounce<T>(value: T, delay: number): T {
const [debounced, setDebounced] = useState(value);
useEffect(() => {
const timer = setTimeout(() => setDebounced(value), delay);
return () => clearTimeout(timer);
}, [value, delay]);
return debounced;
}
// Usage
const search = useDebounce(query, 300);
Performance Checklist
- [ ] Use
React.memo()only when re-renders measured (not prematurely) - [ ] Lazy load below-fold components with
React.lazy()+Suspense - [ ] Virtualize long lists with
@tanstack/react-virtual - [ ] Code-split routes automatically (Next.js does this)
- [ ] Use
useMemo/useCallbackonly when profiling shows benefit
Component Composition
// ✅ Good: Composition over props drilling
function Card({ children }: { children: React.ReactNode }) {
return <div className="card">{children}</div>;
}
function CardHeader({ title }: { title: string }) { return <h3>{title}</h3>; }
function CardBody({ children }: { children: React.ReactNode }) { return <div>{children}</div>; }
// Usage
<Card>
<CardHeader title="Hello" />
<CardBody>Content here</CardBody>
</Card>
Pitfalls
- Prop drilling 3+ levels → Use Context or composition
- useEffect for derived state → Compute during render instead
- Object/array in useEffect deps → Use primitive deps or
useMemo - Index as key → Use stable unique IDs
- Over-optimizing early → Profile first, optimize second
Verification
- [ ] Components render without errors
- [ ] State updates trigger correct re-renders
- [ ] No unnecessary re-renders (React DevTools Profiler)
- [ ] Loading and error states handled
- [ ] Accessible (keyboard nav, screen readers)
04 同仓库更多 Skills
security-audit
Security guidance and vulnerability review for codebases, APIs, services, CLI tools, libraries, and daemons. Use for security questions, focused reviews, vulnerability research, security audits, or pen tests. Run the complete workflow only for explicit codebase audit or pen-test requests, full/comprehensive/end-to-end reviews, or requested report artifacts.
impeccable
Use when the user wants to design, redesign, shape, critique, audit, polish, simplify, harden, animate, or otherwise improve a frontend interface: websites, landing pages, dashboards, product UI, components, forms, settings, onboarding, empty states, and native iOS or Android screens. Handles UX review, hierarchy, layout, typography, color, motion, UX copy, accessibility, responsive behavior, edge cases, and capturing or documenting design systems (DESIGN.md, tokens). Also for making bland UI bolder, loud UI quieter, or ambitious visual effects. Not for backend-only or non-UI tasks.
hallmark
Design skill for websites and new pages that look designed, not generated. Use when the user asks to build or design something new, or names Hallmark. Never use it on an existing design unless the user names Hallmark, as in `/hallmark redesign <path>`.
webapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
appinsights-instrumentation
Guidance for instrumenting webapps with Azure Application Insights. Provides telemetry patterns, SDK setup, and configuration references. USE FOR: how to instrument app, App Insights SDK, telemetry patterns, what is App Insights, Application Insights guidance, instrumentation examples, APM best practices. DO NOT USE FOR: adding App Insights to my app (use azure-prepare), add telemetry to my project (use azure-prepare), add monitoring (use azure-prepare). This skill provides guidance—azure-prepare orchestrates component changes.
youtube-automation
YouTube automation: upload, SEO, thumbnails, scheduling, analytics.