# How to use Claude to refactor React derived state

A React developer reviewed an initial Claude Code refactor before expanding it to hundreds of edits; most worked, but declaration errors required manual repairs.

Agent: Claude (via Claude Code)
Tools: Claude Code, Opus 4.6, React
Category: Software & DevOps
Date: 2026-03-14

Outcome: Most changes were correct, but some introduced undefined variable references and other mistakes. The author believed it probably saved time despite the frustration.

## Steps

1. Asked for a behavior-preserving derived-state refactor in plan mode.
2. Requested changes to a few files and reviewed the initial batch.
3. Authorized Claude Code to modify the rest of the codebase.
4. Attempted agent-led repairs, then fixed broken code with a teammate.

Human oversight: The developer reviewed the first files and later repaired broken code manually with another developer.

Source: [koreth1 on Hacker News](https://news.ycombinator.com/item?id=47373241)

Canonical URL: https://agentsinuse.com/use-cases/claude-to-refactor-react-derived-state/
