🤖 AI Summary
This work addresses the challenges posed by implicit dependencies introduced by React Hooks, which often lead to anti-patterns that reduce code predictability and maintainability. To tackle this issue, we propose HookLens—the first interactive visualization system specifically designed for React Hooks—that integrates static and dynamic program analysis to explicitly reveal data flows and dependency structures across components. Through an iterative design process, HookLens provides an intuitive interface that enhances developers’ understanding of complex hook-based logic. A user study with 12 developers demonstrates that using HookLens significantly improves the accuracy of anti-pattern identification compared to conventional code editors and state-of-the-art large language model (LLM) coding assistants, thereby validating its effectiveness in supporting code comprehension and quality assurance for React Hooks.
📝 Abstract
Maintaining and refactoring React web applications is challenging, as React code often becomes complex due to its core API called Hooks. For example, Hooks often lead developers to create complex dependencies among components, making code behavior unpredictable and reducing maintainability, i.e., anti-patterns. To address this challenge, we present HookLens, an interactive visual analytics system that helps developers understand howHooks define dependencies and data flows between components. Informed by an iterative design process with experienced React developers, HookLens supports users to efficiently understand the structure and dependencies between components and to identify anti-patterns. A quantitative user study with 12 React developers demonstrates that HookLens significantly improves participants'accuracy in detecting anti-patterns compared to conventional code editors. Moreover, a comparative study with state-of-the-art LLM-based coding assistants confirms that these improvements even surpass the capabilities of such coding assistants on the same task.