跳到主内容
智客 ZICQ

技能库 智客分类:数据与分析 react-performance-optimization

React Performance Optimization

利用记忆化,代码分拆,高效渲染策略来反应性能优化模式. 优化慢回放应用程序时使用,减少捆绑大小,或改进大数据集的用户体验.

1900 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

利用记忆、代码分拆和高效渲染策略,反应性能优化模式

何时用

这个技能

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:React Performance Optimization、When to Use This Skill、Core Concepts、React Rendering Optimization、When to Optimize、Quick Reference。 其中含规范建议的小节:分步指令。

文件分析

文件分析:除 SKILL.md 外,正文引用了 references/memoization.md、references/code-splitting.md、references/virtualization.md、references/state-management.md、references/concurrent-features.md、references/profiling-debugging.md,属于带资源的技能包,这些文件按需再读。

官方 description(原文)

React performance optimization patterns using memoization, code splitting, and efficient rendering strategies. Use when optimizing slow React applications, reducing bundle size, or improving user experience with large datasets.

React Performance OptimizationWhen to Use This SkillCore ConceptsReact Rendering OptimizationWhen to OptimizeQuick ReferenceOptimization Workflow1. Identify BottlenecksOpen React DevTools ProfilerRecord interaction → Analyze flame graph → Find slow components2. Apply Targeted Optimizations3. Verify Improvements

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
react-performance-optimization
description
React performance optimization patterns using memoization, code splitting, and efficient rendering strategies. Use when optimizing slow React applications, reducing bundle size, or improving user experience with large datasets.
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。
指令中引用的文件 · 7
  • references/memoization.md
  • references/code-splitting.md
  • references/virtualization.md
  • references/state-management.md
  • references/concurrent-features.md
  • references/profiling-debugging.md
  • references/common-pitfalls.md

以下路径提取自原文;文件是否齐全请以来源仓库中的完整目录为准。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

该技能引用了附属文件,请从来源获取完整目录;仅复制 SKILL.md 可能缺少依赖。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「react-performance-optimization」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-b470937bb8796fad-%E5%8F%8D%E5%BA%94%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96.html
请存为 .cursor/skills/react-performance-optimization/SKILL.md 或 .claude/skills/react-performance-optimization/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。
该技能还带 scripts/、references/、assets/ 等文件,请从 https://github.com/nickcrew/claude-cortex 取完整目录,不要只建一个 SKILL.md。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/nickcrew/claude-cortex' --list

npx skills add 'https://github.com/nickcrew/claude-cortex' --skill 'react-performance-optimization'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: react-performance-optimization description: React performance optimization patterns using memoization, code splitting, and efficient rendering strategies. Use when optimizing slow React applications, reducing bundle size, or improving user experience with large datasets. keywords: - React optimization - React performance - React.memo - bundle size - code splitting - lazy loading - re-render - useCallback - useMemo - virtualization file_patterns: - '**/*.spec.ts' - '**/*.test.ts' - '**/*.test.tsx' - '**/*.ts' - '**/*.tsx' - '**/package.json' - '**/tests/**/*.ts' - '**/tests/**/*.tsx' - '**/tsconfig.json' confidence: 0.76 --- # React Performance Optimization Expert guidance for optimizing React application performance through memoization, code splitting, virtualization, and efficient rendering strategies. ## When to Use This Skill - Optimizing slow-rendering React components - Reducing bundle size for faster initial load times - Improving responsiveness for large lists or data tables - Preventing unnecessary re-renders in complex component trees - Optimizing state management to reduce render cascades - Improving perceived performance with code splitting - Debugging performance issues with React DevTools Profiler ## Core Concepts ### React Rendering Optimization React re-renders components when props or state change. Unnecessary re-renders waste CPU cycles and degrade user experience. Key optimization techniques: - **Memoization**: Cache component renders and computed values - **Code splitting**: Load code on demand for faster initial loads - **Virtualization**: Render only visible list items - **State optimization**: Structure state to minimize render cascades ### When to Optimize 1. **Profile first**: Use React DevTools Profiler to identify actual bottlenecks 2. **Measure impact**: Verify optimization improves performance 3. **Avoid premature optimization**: Don't optimize fast components ## Quick Reference Load detailed patterns and examples as needed: | Topic | Reference File | | --- | --- | | React.memo, useMemo, useCallback patterns | `skills/react-performance-optimization/references/memoization.md` | | Code splitting with lazy/Suspense, bundle optimization | `skills/react-performance-optimization/references/code-splitting.md` | | Virtualization for large lists (react-window) | `skills/react-performance-optimization/references/virtualization.md` | | State management strategies, context splitting | `skills/react-performance-optimization/references/state-management.md` | | useTransition, useDeferredValue (React 18+) | `skills/react-performance-optimization/references/concurrent-features.md` | | React DevTools Profiler, performance monitoring | `skills/react-performance-optimization/references/profiling-debugging.md` | | Common pitfalls and anti-patterns | `skills/react-performance-optimization/references/common-pitfalls.md` | ## Optimization Workflow ### 1. Identify Bottlenecks ```bash # Open React DevTools Profiler # Record interaction → Analyze flame graph → Find slow components ``` **Look for:** - Components with yellow/red bars (slow renders) - Unnecessary renders (same props/state) - Expensive computations on every render ### 2. Apply Targeted Optimizations **For unnecessary re-renders:** - Wrap component with `React.memo` - Use `useCallback` for stable function references - Check for inline objects/arrays in props **For expensive computations:** - Use `useMemo` to cache results - Move calculations outside render when possible **For large lists:** - Implement virtualization with react-window - Ensure proper unique keys (not index) **For slow initial load:** - Add code splitting with `React.lazy` - Analyze bundle size with webpack-bundle-analyzer - Use dynamic imports for heavy dependencies ### 3. Verify Improvements ```bash # Record new Profiler session # Compare before/after metrics # Ensure optimization actually helped ``` ## Common Patterns ### Memoize Expensive Components ```jsx import { memo } from 'react'; const ExpensiveList = memo(({ items, onItemClick }) => { return items.map(item => ( )); }); ``` ### Cache Computed Values ```jsx import { useMemo } from 'react'; function DataTable({ items, filters }) { const filteredItems = useMemo(() => { return items.filter(item => filters.includes(item.category)); }, [items, filters]); return ; } ``` ### Stable Function References ```jsx import { useCallback } from 'react'; function Parent() { const handleClick = useCallback((id) => { console.log('Clicked:', id); }, []); return ; } ``` ### Code Split Routes ```jsx import { lazy, Suspense } from 'react'; const Dashboard = lazy(() => import('./Dashboard')); const Reports = lazy(() => import('./Reports')); function App() { return ( }> } /> } /> ); } ``` ### Virtualize Large Lists ```jsx import { FixedSizeList } from 'react-window'; function VirtualList({ items }) { return ( {({ index, style }) => (
{items[index].name}
)} ); } ``` ## Common Mistakes 1. **Over-memoization**: Don't memoize simple, fast components (adds overhead) 2. **Inline objects/arrays**: New references break memoization (`config={{ theme: 'dark' }}`) 3. **Missing dependencies**: Stale closures in useCallback/useMemo 4. **Index as key**: Breaks reconciliation when list order changes 5. **Single large context**: Causes widespread re-renders on any update 6. **No profiling**: Optimizing without measuring wastes time ## Performance Checklist Before optimizing: - [ ] Profile with React DevTools to identify bottlenecks - [ ] Measure baseline performance metrics Optimization targets: - [ ] Memoize expensive components with stable props - [ ] Cache computed values with useMemo (if actually expensive) - [ ] Use useCallback for functions passed to memoized children - [ ] Implement code splitting for routes and heavy components - [ ] Virtualize lists with >100 items - [ ] Provide stable keys for list items (unique IDs, not index) - [ ] Split state by update frequency - [ ] Use concurrent features (useTransition, useDeferredValue) for responsiveness After optimizing: - [ ] Profile again to verify improvements - [ ] Check bundle size reduction (if applicable) - [ ] Ensure no regressions in functionality ## Resources - **React Docs - Performance**: https://react.dev/learn/render-and-commit - **React DevTools**: Browser extension for profiling - **react-window**: https://github.com/bvaughn/react-window - **Bundle analyzers**: webpack-bundle-analyzer, rollup-plugin-visualizer - **Lighthouse**: Chrome DevTools performance audit

相关技能

数据与分析

Marketing Skills

TL; DR:23个营销剧本(CRO,SEO,拷贝,分析,实验,定价,发布,广告,社交). 用于快速获取清单+副本/粘贴可交付品.

数据与分析

Crypto & Stock Market Data (Node.js)

免费等级不需要 API 关键值 。 专业级别的密码货币和股票市场数据集成,用于实时价格、公司概况和全球分析。 由Node.js提供动力,外部依赖性为零.

数据与分析

Azure Storage

Azure存储服务包括Blob存储,文件共享,等式存储,表存储,和数据湖. 解答关于存储访问级别(热,凉,冷,存档),何时使用每个级别,以及级别比较的问题. 提供对象存储,SMB文件共享,async消息,NoSQL密钥-值,和大数据分析. 包括生命周期管理。 USE FOR: b…

数据与分析

Azure Kusto

Azure Data Explorer(Kusto/ADX)中使用KQL进行日志分析,遥测和时间序列分析的查询并分析数据. When: KQL 查询, Kusto 数据库查询, Azure Data Explorer, ADX 集群, 日志分析, 时间序列数据, IoT 遥测, …