react-best-practices
React 18 best practices including hooks, performance, state management with Zustand, data fetching with React Query, and TypeScript patterns. Use when building React components, hooks, or optimizing React performance.
- License 许可
- MIT
- 最近更新
- 2026-05-18
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- react-best-practices
- description
- React 18 best practices including hooks, performance, state management with Zustand, data fetching with React Query, and TypeScript patterns. Use when building React components, hooks, or optimizing React performance.
03 SKILL.md 正文
React Best Practices for Aurion Studio
Component Patterns
- Prefer function components with hooks
- Keep components under 300 lines — extract sub-components
- Co-locate related files (Component, hook, types, test)
- Use forwardRef for components that need ref access
- Default export for page components, named exports for utility components
TypeScript Strict
- ZERO
any— use proper types always - Define interfaces for props:
interface Props { ... } - Use discriminated unions for complex state
- Generic components when appropriate:
<List<T>> - Strict null checks enforced
Hooks
- Custom hooks for reusable logic:
useCredits(),useAuth() - Always specify dependency arrays correctly
useMemofor expensive computationsuseCallbackfor callbacks passed to child componentsuseReffor values that don't trigger re-renders
State Management (Zustand)
- One store per feature domain
- Keep stores flat (no deep nesting)
- Use selectors to minimize re-renders:
useStore(state => state.count) - Actions inside the store, not in components
- Persist critical state with Zustand middleware
Data Fetching (React Query)
useQueryfor GET requests with cachinguseMutationfor POST/PUT/DELETE with optimistic updates- Set
staleTimeandgcTimeappropriately - Invalidate queries after mutations
- Error boundary integration for query errors
Performance
React.lazy()for route-level code splittingReact.memo()for expensive pure components- Virtualize long lists (react-window or tanstack-virtual)
- Debounce search inputs and resize handlers
- Use
Suspensewith lazy components
Styling (Tailwind CSS)
- Utility-first, no custom CSS unless absolutely needed
- Use
cn()utility for conditional classes - Responsive: mobile-first (
sm:,md:,lg:) - Aurion palette: bg-[#F2F2F2], text-[#0D0D0D], rounded-3xl (24px)
- Typography: font-serif italic for display, font-sans for body
Framer Motion
- Use
motioncomponents for animations AnimatePresencefor exit animationswhileInViewfor scroll-triggered animations- Keep animations subtle and performant (transform-only)
- Reduce motion for accessibility:
prefers-reduced-motion
Error Handling
- Error Boundaries for component tree errors
try/catchin async functions- Display user-friendly error messages
- Log errors for debugging (not in production console)
- Fallback UI for loading and error states
04 同仓库更多 Skills
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.
web-design-guidelines
Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".
vercel-react-view-transitions
Guide for implementing smooth, native-feeling animations using React's View Transition API (`<ViewTransition>` component, `addTransitionType`, and CSS view transition pseudo-elements). Use this skill whenever the user wants to add page transitions, animate route changes, create shared element animations, animate enter/exit of components, animate list reorder, implement directional (forward/back) navigation animations, or integrate view transitions in Next.js. Also use when the user mentions view transitions, `startViewTransition`, `ViewTransition`, transition types, or asks about animating between UI states in React without third-party animation libraries.
vercel-react-best-practices
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
vercel-composition-patterns
React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.
vercel-cli-with-tokens
Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".