本文へスキップ
Skillpedia
WebサイトとUI(フロントエンド)40k · #7390

react19-source-patterns

できること

このガイドは、React 19向けにReactコードを更新する手助けをします。新しいバージョンで動かなくなったり、位置が変わったりしたコードの特定部分をどのように変更すればよいかを示します。

使う場面

  • ✓ReactプロジェクトをReact 19に更新するとき。
  • ✓更新後にReactコードの一部が動かなくなったとき。
  • ✓特定のファイルで必要な変更を把握したいとき。

スキルのリンク

https://github.com/github/awesome-copilot/blob/main/skills/react19-source-patterns/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/github/awesome-copilot/blob/main/skills/react19-source-patterns/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“React 19向けに`ReactDOM.render`を更新するにはどうすればよいですか?”

毎週5つの新しいスキル。1分で読めます。

仕組み

AIが、現在のコードとReact 19の移行パターンを比較します。そのうえで、コードの各部分に必要な正確な変更を提案します。例えば、`ReactDOM.render`を`createRoot().render()`に置き換えるといった内容です。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

React 19 Source Migration Patterns

Reference for every source-file migration required for React 19.

Quick Reference Table

Pattern Action Reference
ReactDOM.render(...) → createRoot().render() See references/api-migrations.md
ReactDOM.hydrate(...) → hydrateRoot(...) See references/api-migrations.md
unmountComponentAtNode → root.unmount() Inline fix
ReactDOM.findDOMNode → direct ref Inline fix
forwardRef(...) wrapper → ref as direct prop See references/api-migrations.md
Component.defaultProps = {} → ES6 default params See references/api-migrations.md
useRef() no arg → useRef(null) Inline fix add null
Legacy Context → createContext → api-migrations.md#legacy-context
String refs this.refs.x → createRef() → api-migrations.md#string-refs
import React from 'react' (unused) Remove Only if no React. usage in file

PropTypes Rule

Do not remove .propTypes assignments. The prop-types package still works as a standalone validator. React 19 only removes the built-in runtime checking from the React package the package itself remains valid.

Add this comment above any .propTypes block:

// NOTE: React 19 no longer runs propTypes validation at runtime.
// PropTypes kept for documentation and IDE tooling only.

Read the Reference

For full before/after code for each migration, read references/api-migrations.md. It contains the complete patterns including edge cases for forwardRef with useImperativeHandle, defaultProps null vs undefined behavior, and legacy context provider/consumer cross-file migrations.

よくある質問

`.propTypes`を削除する必要はありますか?

いいえ、削除する必要はありません。`.propTypes`はバリデーターとして引き続き機能しますが、React 19では自動的には実行されなくなります。ドキュメントやツールのために残しておくのがよいでしょう。

「String refs」とは何ですか?

Reactで要素を参照する古い方法です(例: `this.refs.myElement`)。React 19では代わりに`createRef()`の使用が推奨されています。

引数なしの`useRef()`はどうすればよいですか?

初期値を指定せずに`useRef()`を使っている場合、React 19では引数に`null`を追加して`useRef(null)`とすることが求められます。

詳細

作者による元の説明

Reference for React 19 source-file migration patterns, including API changes, ref handling, and context updates.

repo: github/awesome-copilot

人気

GitHubのスター
40k
ランキング
#7390
ライセンス
MIT
更新日
2026/10/15

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル