⚙️ 自動化 コミュニティ

Reactクラスコンポーネントを関数コンポーネントに一括リファクタリング

Coworkを使用してレガシーReactクラスコンポーネントをHooks付き関数コンポーネントに変換、ロジックをカスタムHooksに分割、テストを作成。5分で完了

★★☆ 中級 5-15 min 2026年2月1日
A
AI Blew My Mind @@aiblewmymind
ソース
📋

シナリオ

開発者にはモダン化が必要な複数のレガシーReactクラスコンポーネントがあった。Coworkがクラスから関数への変換、Hooks移行、カスタムHook抽出、テスト作成を処理。

💬

プロンプト

I have legacy React class components that need to be modernized:
1. Convert all class components to functional components with Hooks
2. Extract reusable logic into custom Hooks
3. Write unit tests for the refactored components
Here are the component files: [attach files]

期待される結果

全てのリファクタリングが5分で完了、「完璧に動作」。クラスコンポーネントが関数型に変換、ロジックがカスタムHooksに分割、全テスト合格。