HookLens: Visual Analytics for Understanding React Hooks Structures

Suyeon Hwang, Minkyu Kweon, Jeongmin Rhee, Soohyun Lee, Seokhyeon Park, Seokweon Jung, Hyeon Jeon, Jinwook SeoarXiv 2026

TL;DR

HookLens is an interactive visual analytics tool designed to help developers untangle the complex web of component dependencies and data flows introduced by React Hooks. By visualizing code structures as a nested node-link diagram, it enables developers to rapidly detect tricky architectural anti-patterns like prop drilling. In controlled evaluations, HookLens significantly outperformed traditional code editors and even surpassed state-of-the-art LLM coding assistants in accurately identifying multi-file hook dependencies.

What Problem Does This Paper Address?

React’s component-based architecture is a staple of modern web development, allowing developers to build self-contained user interface elements. To manage state and side effects within these functional components, React relies heavily on "Hooks" (such as useState and useEffect).

However, as applications scale, Hooks often introduce implicit, highly complex dependencies that cross component boundaries and span multiple files. This complexity frequently breeds architectural anti-patterns:

  • Prop Drilling: Passing state values through multiple intermediate components that don't actually use the data, just to reach a deeply nested child component.
  • Unreferenced States and Props: Unused variables that waste memory and clutter code.
  • Effects Modifying Parent States: Child components triggering side effects that alter parent states, creating unpredictable re-render loops and bugs.

Detecting these patterns in standard text editors (like VS Code) requires tedious manual code tracing. Even advanced Large Language Model (LLM) coding assistants struggle with this task because it requires deep, multi-file contextual reasoning.

Methods

The authors developed HookLens, a visual analytics system that combines static code analysis with an interactive user interface.

  1. Data Extraction Pipeline: HookLens ingests React source code (.jsx or .tsx files) and parses it into Abstract Syntax Trees (ASTs) using the TypeScript compiler API and the open-source JavaScript parser, Espree. A rule-based extractor then analyzes the ASTs to map out Components, Props, States, Effects, and their reference relationships.
  2. Visual Analytics Interface: The system translates this extracted data into a nested, directed node-link diagram. Component nodes are arranged horizontally by hierarchy. Clicking a Component node expands it to reveal its internal Props, States, and Effects.
  3. Interactive Exploration: Following the classic visual information-seeking mantra ("overview first, zoom and filter, details-on-demand"), users can click on any specific state or hook node to highlight its entire dependency graph while dimming unrelated elements. Potential anti-patterns are automatically flagged with animated red outlines. Crucially, HookLens integrates a synchronized code viewer that jumps directly to the relevant lines of source code when a node is selected.
Figure 1: The overview of HOOKLENS. The nested directed node-link diagram visualizes the structure of a React application. Nodes represent Components, Props, and Hooks—key elements for understanding React—and edges indicate their relationships. Nodes for Props and Hooks are nested within Component nodes and are initially hidden. Users can click a Component node to reveal its internal Props, Hooks and their relationships, and then examine these details (A). Users can also click a Prop or Hook node to highlight its relevant nodes and edges (B). Potentially problematic Components, Props, Hooks, and relationships are highlighted with red outlines and edges (C). Moreover, users can view the associated source code in the code viewer (D).

Datasets

To evaluate HookLens, the authors selected two open-source React applications developed by individuals/small teams, serving as realistic academic prototypes:

  • Confides: An automated speech recognition analysis tool consisting of 25 components and ~2,707 lines of JSX code.
  • paper_vis: A data visualization prototype consisting of 33 components and ~3,937 lines of JSX code.

These projects were chosen because they contained a representative density of naturally occurring hook-related anti-patterns, making them ideal for controlled maintenance and refactoring tests.

Key Insights and Ideas

  • The Hook Problem Space: By analyzing Stack Overflow data from 2020 to 2024, the authors found that useState and useEffect alone account for a staggering 82% of all hook-related questions, validating their decision to focus HookLens primarily on these two features.
Figure 2: Ratio of posts about each built-in Hook on Stack Overflow (2020–2024). Data are obtained by querying posts tagged with re- actjs that mention the name of each Hook using the Stack Exchange API (https://api.stackexchange.com/). useState and useEffect denote the functions for the State and Effect Hooks, respectively.
  • Novice vs. Expert Workflows: The user study revealed a fascinating split in how developers use visual tools. Novice developers relied almost entirely on the visual diagram and its red warning cues to spot bugs quickly without reading the underlying code. Intermediate developers used the visualization as a high-level map, repeatedly cross-referencing it with the raw source code to verify application logic.
  • LLMs Stumble on Multi-File Context: While LLMs are excellent at localized code generation, they frequently hallucinated dependencies or missed extensive prop-drilling chains when evaluating entire project directories. This underscores the ongoing necessity of human-in-the-loop visual analytics tools for complex software architecture tasks.

Key Results

The authors conducted a user study with 12 React developers comparing HookLens against a baseline VS Code environment, alongside a comparative study against state-of-the-art LLMs (including Claude Code, Gemini, and Codex/GPT-5).

  • Higher Accuracy: Participants using HookLens achieved significantly higher F1-scores and recall in detecting anti-patterns compared to using VS Code. For instance, in identifying prop drilling, the average F1-score jumped from 0.264 (VS Code) to 0.669 (HookLens).
  • Strong Usability: HookLens achieved an average System Usability Scale (SUS) score of 76.7, comfortably exceeding the standard acceptability benchmark of 68.
  • Outperforming AI Assistants: HookLens consistently beat Claude Code, Gemini, and GPT-5 in precision. The LLMs frequently suffered from false positives, incorrectly flagging imported relationships that were never actually executed in the code.

Limitations and Future Work

While HookLens proved highly effective, the authors noted several areas for improvement:

  • Scalability Clutter: The system was evaluated on small-to-medium codebases (up to 33 components). For massive production codebases, the node-link diagram risks becoming a tangled "spaghetti" chart. The authors suggest exploring alternative layouts like treemaps or icicle trees for larger projects.
  • Ecosystem Limitations: HookLens currently lacks support for external state management libraries (like Redux) or other built-in React features like the Context API, which developers frequently use to bypass prop drilling.
  • Static vs. Dynamic Analysis: Because HookLens relies purely on static analysis, it cannot track dynamic runtime behaviors, such as exact execution timings or conditional state changes that only happen during live app usage.

Summary updated

BibTeX
@misc{hwang2026hooklens,
  author = {Suyeon Hwang and Minkyu Kweon and Jeongmin Rhee and Soohyun Lee and Seokhyeon Park and Seokweon Jung and Hyeon Jeon and Jinwook Seo},
  title = {{HookLens: Visual Analytics for Understanding React Hooks Structures}},
  year = {2026},
  eprint = {2602.17891},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.17891},
}
Figure