← 返回
未分类 中文

React Best Practices

Audits React code for performance, bundle size, and best practices. Use when reviewing React code, auditing bundle size, finding performance issues, checking...
对React代码进行性能、包体积和最佳实践审计,适用于代码审查、包体积审计和性能问题定位等场景。
asimons81 asimons81 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 384
下载
💾 0
安装
1
版本
#latest

概述

React Best Practices Skill

Audits React applications for performance, bundle size, and React 18+ best practices.

Instructions

When reviewing or auditing React code:

  1. Run the audit against the specified code or repository
  2. Check against the 40+ auditable rules (see below)
  3. Report findings with severity (error, warning, info)
  4. Provide actionable fix suggestions with before/after code examples
  5. For performance issues, identify the root cause and recommended optimization
  6. For bundle issues, suggest code splitting or lazy loading strategies

Auditable Rules (Sample)

Performance

  • no-missing-deps: Hook dependencies must be complete
  • avoid-inline-objects-in-jsx: Inline objects cause unnecessary re-renders
  • prefer-useMemo: Expensive computations should use useMemo
  • prefer-useCallback: Callbacks passed to children should use useCallback

React 18+

  • prefer-use client directive: Server Components compliance
  • no-unnecessary-fragments: Avoid unnecessary fragment wrappers
  • require-useTransition: Long renders should use useTransition

Bundle Size

  • no-bare-imports: Use named imports over namespace imports
  • avoid-default-imports: Default imports prevent tree shaking
  • check-duplicate-packages: Duplicate package versions inflate bundle

Accessibility

  • require-aria-labels: Interactive elements need ARIA labels
  • require-keyboard-handlers: Click handlers need keyboard equivalents

Output Format

{
  "file": "src/components/UserProfile.tsx",
  "rules": [
    {
      "rule": "no-missing-deps",
      "severity": "error",
      "line": 42,
      "message": "Missing dependency 'userId' in useEffect",
      "fix": "Add userId to dependency array"
    }
  ],
  "summary": { "errors": 2, "warnings": 5, "info": 1 }
}

Example

User: "Audit our React codebase for performance issues"

→ Run audit → Report: 3 errors (missing deps, inline objects), 7 warnings → Provide fixes for each

Dependencies

Requires: Node.js, project with React 16+ (for React 18+ rules, requires React 18+)

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-07 04:45 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 683 📥 330,503
dev-programming

Mcporter

steipete
使用 mcporter CLI 直接列出、配置、认证及调用 MCP 服务器/工具(支持 HTTP 或 stdio),涵盖临时服务器、配置编辑及 CLI/类型生成功能。
★ 197 📥 68,112
knowledge-management

Obsidian Organizer

asimons81
组织和规范化 Obsidian 库,以确保可靠性与长期可维护性。适用于设计或清理库文件夹结构、强制文件……
★ 1 📥 1,346