r/reactjs • • 3d ago

I built an open-source tool that replays real React hook executions one statement at a time

Most hook bugs are timing bugs: two setCount(count + 1) calls that only increment once, a stale closure from an empty dependency array, a fetch race where an old response overwrites a new one. They're hard to see from the code alone.

HookViz replays real React executions statement by statement. The source line, hook list, effects queue, variables and rendered DOM all show the same moment.

- Each example is recorded from a real component under a debugger, not simulated

- 22 examples on React 19, from useState and useEffect to useOptimistic and useTransition

- Play, pause, step and seek, 0.5x to 4x speed, Guided and Expert modes

- Open source, and new examples are welcome

Live: https://hookviz.ashishtaduce.co.in

Repo: https://github.com/AshishTaduce/hookviz

The batching example is the quickest one to try. I'd like to hear which hook behaviours you'd want to see next.

0 Upvotes

2 comments sorted by

1

u/Minute-Age9938 3d ago

The two setCount(count + 1) calls are the bug a statement replay should make obvious. Both close over the same count, so the second write replaces the first and you only increment once. A stale closure from an empty dependency array shows up the same way if you can step into the effect and see the value it captured. I would not trust one replay to catch the fetch race. That one is two responses, and the bug is that the older response lands last. If the tool only replays a single execution, you still need the second response on a timeline or the component looks fine.