Skip to content

useMemo と useCallback の依存値の比較対象を明確にする - #1012

Merged
honey32 merged 1 commit into
reactjs:mainfrom
yotatameguchi-boop:docs/clarify-dependency-element-comparison
Nov 28, 2026
Merged

honey32 merged 1 commit into
reactjs:mainfrom
yotatameguchi-boop:docs/clarify-dependency-element-comparison

Conversation

@yotatameguchi-boop

Copy link
Copy Markdown
Contributor

useMemo と useCallback の使用法で、Object.is の比較対象が依存配列そのものだと読める説明を修正します。

例えば、[todos, tab] はレンダーのたびに新しい配列になりますが、各依存値が変化しなければキャッシュは再利用されます。現在の訳文では「依存配列と、前回の依存配列が比較されます」「依存配列が変更されていない場合」と説明しており、配列の参照同一性で判定されるという誤解につながる可能性があります。

両ページで、配列内の各依存値を前回の対応する依存値と比較することを明記します。直後の要約も「依存値」が変わるまでキャッシュするという表現に揃えます。これは英語原文の “none of the dependencies have changed” と、同ページの引数リファレンスにある説明に沿った修正です。

英語原文:

検証:

  • 対象 2 ページの textlint と git diff --check:成功
  • React 19.0.0 と react-test-renderer 19.0.0 を使い、再レンダー時に依存配列を新規作成しても同じ要素なら両フックの返り値の同一性と計算回数が維持されることを確認
  • プリミティブ値を変更した場合、および同じ内容の新しいオブジェクトを依存値に渡した場合は、両フックのキャッシュが更新されることを確認
  • コード例、リンク先 URL、見出しアンカー、CodeStep タグ、行数が変更前と一致することを確認

ブラウザ上の表示確認は未実施です。

@vercel

vercel Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
legacy-ja-reactjs-org Ignored Ignored Preview Oct 15, 2026 7:48am UTC

Request Review

@smikitky smikitky left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

はい、ちょびっと意訳気味ではありますが良いと思います

@smikitky
smikitky requested review from honey32 and a balanced review from Copilot November 27, 2026 05:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the documentation-only clarification of how dependency values are compared.

No open issues 🎉

What changed in this PR

React の日本語リファレンスで、useMemo と useCallback の依存値比較の説明を明確にします。ドキュメントのみの変更で、実装やコード例は変わりません。

Changes:

  • Object.is の比較対象が、依存配列自体ではなく、前回と今回の対応する各依存値であることを明記。
  • キャッシュについての要約を「依存値」が変わるまでという表現に統一。
File Description
src/​content/​reference/​react/​useMemo.md 依存値の比較と計算結果のキャッシュに関する説明を修正。
src/​content/​reference/​react/​useCallback.md 依存値の比較と関数のキャッシュに関する説明を修正。

Review effort: Balanced

@honey32 honey32 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@honey32
honey32 merged commit de36eba into reactjs:main Nov 28, 2026
7 checks passed

This branch was successfully deployed

1 active deployment
Preview – ja-react-dev — 0dffbe41 Deployed Oct 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants