React Class to Hooks Transformation (Codebase-wide)
Incrementally modernize an entire React codebase from class components to hooks.
category:modernization
react
hooks
refactor
workflow
multi-step
0
Prompt
Use this workflow when you want to adopt hooks across a mature React codebase while reducing risk. ## Steps: 1. Inventory all class components and categorize by complexity. 2. Start with leaf components that have simple lifecycle logic. 3. Convert lifecycle methods (componentDidMount, etc.) to useEffect hooks. 4. Replace this.state and this.setState with useState or useReducer. 5. Extract repeated lifecycle patterns into custom hooks. 6. Run component-level tests or snapshots to verify behavior. 7. Convert container components last, after shared hooks are stable.