🛠️ React Component Performance
Reactコンポーネントの遅延原因を特定し、具体的なパフォーマンス改善策を提案するSkill。
📺 まず動画で見る(YouTube)
▶ 【衝撃】最強のAIエージェント「Claude Code」の最新機能・使い方・プログラミングをAIで効率化する超実践術を解説! ↗
※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。
📜 元の英語説明(参考)
Diagnose slow React components and suggest targeted performance fixes.
🇯🇵 日本人クリエイター向け解説
Reactコンポーネントの遅延原因を特定し、具体的なパフォーマンス改善策を提案するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o react-component-performance.zip https://jpskill.com/download/3359.zip && unzip -o react-component-performance.zip && rm react-component-performance.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/3359.zip -OutFile "$d\react-component-performance.zip"; Expand-Archive "$d\react-component-performance.zip" -DestinationPath $d -Force; ri "$d\react-component-performance.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
react-component-performance.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
react-component-performanceフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-17
- 同梱ファイル
- 2
💬 こう話しかけるだけ — サンプルプロンプト
- › React Component Performance を使って、最小構成のサンプルコードを示して
- › React Component Performance の主な使い方と注意点を教えて
- › React Component Performance を既存プロジェクトに組み込む方法を教えて
これをClaude Code に貼るだけで、このSkillが自動発動します。
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Reactコンポーネントのパフォーマンス
概要
レンダーのホットスポットを特定し、コストのかかる更新を分離し、UIの動作を変更することなく的を絞った最適化を適用します。
使用する場面
- ユーザーが遅いReactコンポーネントのプロファイリングまたは改善を求めている場合。
- React UIにおける再レンダー、リストの遅延、またはコストのかかるレンダー作業を削減する必要がある場合。
ワークフロー
- 遅延を再現または記述します。
- 何が再レンダーをトリガーしているかを特定します(stateの更新、propsのチャーン、effects)。
- 頻繁に変化するstateを重いサブツリーから分離します。
- propsとハンドラーを安定させ、効果がある場合はメモ化します。
- コストのかかる作業(計算、DOMサイズ、リストの長さ)を削減します。
- 検証: React DevTools Profilerを開き、インタラクションを記録し、Flamegraphで約16ミリ秒以上レンダーされているコンポーネントを検査し、最適化前のベースライン記録と比較します。
チェックリスト
- 測定: React DevTools Profilerを使用するか、レンダーをログに記録し、ベースラインをキャプチャします。
- チャーンの発見: タイマー、スクロール、入力、またはアニメーションで更新されるstateを特定します。
- 分割: チックするstateを子に移動させ、重いリストは静的に保ちます。
- メモ化: propsが安定している場合にのみ、リーフ行を
memoでラップします。 - propsの安定化: ハンドラーと派生値には
useCallback/useMemoを使用します。 - レンダー内での派生作業の回避: 事前計算するか、メモ化されたヘルパー内で計算します。
- リストサイズの制御: 長いリストはウィンドウ化/仮想化し、非表示のアイテムのレンダーを避けます。
- Keys: 安定したキーを確保し、順序が変更される可能性がある場合はインデックスを避けます。
- Effects: 依存配列を確認し、すべてのレンダーで再実行されるeffectを避けます。
- スタイル/レイアウト: コストのかかるレイアウトスラッシュや、大きなMarkdown/diffのレンダーに注意します。
最適化パターン
チックするstateの分離
タイマーやアニメーションカウンターを子に移動させることで、親リストが各ティックで再レンダーされるのを防ぎます。
// ❌ Before – 親全体(およびリスト)が毎秒再レンダーされます
function Dashboard({ items }: { items: Item[] }) {
const [tick, setTick] = useState(0);
useEffect(() => {
const id = setInterval(() => setTick(t => t + 1), 1000);
return () => clearInterval(id);
}, []);
return (
<>
<Clock tick={tick} />
<ExpensiveList items={items} /> {/* re-renders every second */}
</>
);
}
// ✅ After – <Clock>のみが再レンダーされ、リストは変更されません
function Clock() {
const [tick, setTick] = useState(0);
useEffect(() => {
const id = setInterval(() => setTick(t => t + 1), 1000);
return () => clearInterval(id);
}, []);
return <span>{tick}s</span>;
}
function Dashboard({ items }: { items: Item[] }) {
return (
<>
<Clock />
<ExpensiveList items={items} />
</>
);
}
useCallback + memoによるコールバックの安定化
// ❌ Before – 各レンダーで新しいハンドラー参照がRowのメモ化を無効にします
function List({ items }: { items: Item[] }) {
const handleClick = (id: string) => console.log(id); // new ref each render
return items.map(item => <Row key={item.id} item={item} onClick={handleClick} />);
}
// ✅ After – 安定したハンドラー。Rowは自身のitemが変更された場合にのみ再レンダーされます
const Row = memo(({ item, onClick }: RowProps) => (
<li onClick={() => onClick(item.id)}>{item.name}</li>
));
function List({ items }: { items: Item[] }) {
const handleClick = useCallback((id: string) => console.log(id), []);
return items.map(item => <Row key={item.id} item={item} onClick={handleClick} />);
}
レンダー外での派生データの優先
// ❌ Before – 各レンダーで再計算されます
function Summary({ orders }: { orders: Order[] }) {
const total = orders.reduce((sum, o) => sum + o.amount, 0); // runs every render
return <p>Total: {total}</p>;
}
// ✅ After – ordersが変更された場合にのみ再計算されます
function Summary({ orders }: { orders: Order[] }) {
const total = useMemo(() => orders.reduce((sum, o) => sum + o.amount, 0), [orders]);
return <p>Total: {total}</p>;
}
その他のパターン
- 行の分割: リストの行を、狭いpropsを持つメモ化されたコンポーネントに抽出します。
- 重いレンダーの遅延: コストのかかるコンテンツは、展開されるまで遅延レンダーまたは折りたたみます。
プロファイリング検証手順
- React DevTools → Profilerタブを開きます。
- Recordをクリックし、遅いインタラクションを実行してからStopします。
- Flamegraphビューに切り替えます。コンポーネントと時間が約16ミリ秒を超えているバーは候補です。
- Ranked chartを使用して自己レンダー時間でソートし、上位の犯人を特定します。
- 一度に1つの最適化を適用し、再記録し、レンダー回数と期間をベースラインと比較します。
参照例
ユーザーが具体的なリファクタリング例を求めている場合は、references/examples.mdを読み込みます。
制限事項
- このスキルは、タスクが上記の範囲と明確に一致する場合にのみ使用してください。
- 出力を、環境固有の検証、テスト、または専門家によるレビューの代わりとして扱わないでください。
- 必要な入力、権限、安全境界、または成功基準が不足している場合は、停止して明確化を求めてください。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
React Component Performance
Overview
Identify render hotspots, isolate expensive updates, and apply targeted optimizations without changing UI behavior.
When to Use
- When the user asks to profile or improve a slow React component.
- When you need to reduce re-renders, list lag, or expensive render work in React UI.
Workflow
- Reproduce or describe the slowdown.
- Identify what triggers re-renders (state updates, props churn, effects).
- Isolate fast-changing state from heavy subtrees.
- Stabilize props and handlers; memoize where it pays off.
- Reduce expensive work (computation, DOM size, list length).
- Validate: open React DevTools Profiler → record the interaction → inspect the Flamegraph for components rendering longer than ~16 ms → compare against a pre-optimization baseline recording.
Checklist
- Measure: use React DevTools Profiler or log renders; capture baseline.
- Find churn: identify state updated on a timer, scroll, input, or animation.
- Split: move ticking state into a child; keep heavy lists static.
- Memoize: wrap leaf rows with
memoonly when props are stable. - Stabilize props: use
useCallback/useMemofor handlers and derived values. - Avoid derived work in render: precompute, or compute inside memoized helpers.
- Control list size: window/virtualize long lists; avoid rendering hidden items.
- Keys: ensure stable keys; avoid index when order can change.
- Effects: verify dependency arrays; avoid effects that re-run on every render.
- Style/layout: watch for expensive layout thrash or large Markdown/diff renders.
Optimization Patterns
Isolate ticking state
Move a timer or animation counter into a child so the parent list never re-renders on each tick.
// ❌ Before – entire parent (and list) re-renders every second
function Dashboard({ items }: { items: Item[] }) {
const [tick, setTick] = useState(0);
useEffect(() => {
const id = setInterval(() => setTick(t => t + 1), 1000);
return () => clearInterval(id);
}, []);
return (
<>
<Clock tick={tick} />
<ExpensiveList items={items} /> {/* re-renders every second */}
</>
);
}
// ✅ After – only <Clock> re-renders; list is untouched
function Clock() {
const [tick, setTick] = useState(0);
useEffect(() => {
const id = setInterval(() => setTick(t => t + 1), 1000);
return () => clearInterval(id);
}, []);
return <span>{tick}s</span>;
}
function Dashboard({ items }: { items: Item[] }) {
return (
<>
<Clock />
<ExpensiveList items={items} />
</>
);
}
Stabilize callbacks with useCallback + memo
// ❌ Before – new handler reference on every render busts Row memo
function List({ items }: { items: Item[] }) {
const handleClick = (id: string) => console.log(id); // new ref each render
return items.map(item => <Row key={item.id} item={item} onClick={handleClick} />);
}
// ✅ After – stable handler; Row only re-renders when its own item changes
const Row = memo(({ item, onClick }: RowProps) => (
<li onClick={() => onClick(item.id)}>{item.name}</li>
));
function List({ items }: { items: Item[] }) {
const handleClick = useCallback((id: string) => console.log(id), []);
return items.map(item => <Row key={item.id} item={item} onClick={handleClick} />);
}
Prefer derived data outside render
// ❌ Before – recomputes on every render
function Summary({ orders }: { orders: Order[] }) {
const total = orders.reduce((sum, o) => sum + o.amount, 0); // runs every render
return <p>Total: {total}</p>;
}
// ✅ After – recomputes only when orders changes
function Summary({ orders }: { orders: Order[] }) {
const total = useMemo(() => orders.reduce((sum, o) => sum + o.amount, 0), [orders]);
return <p>Total: {total}</p>;
}
Additional patterns
- Split rows: extract list rows into memoized components with narrow props.
- Defer heavy rendering: lazy-render or collapse expensive content until expanded.
Profiling Validation Steps
- Open React DevTools → Profiler tab.
- Click Record, perform the slow interaction, then Stop.
- Switch to Flamegraph view; any bar labeled with a component and time > ~16 ms is a candidate.
- Use Ranked chart to sort by self render time and target the top offenders.
- Apply one optimization at a time, re-record, and compare render counts and durations against the baseline.
Example Reference
Load references/examples.md when the user wants a concrete refactor example.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
同梱ファイル
※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。
- 📄 SKILL.md (5,081 bytes)
- 📎 references/examples.md (2,381 bytes)