POPL 2027
Sun 10 - Sat 16 January 2027 Mexico City, Mexico

React is currently the most popular JavaScript library for front-end web development. It endows UI components with state via the useState construct, in a pattern that we name hook-indexed state. However, React’s implementation of hook-indexed state is both fragile and poorly understood. Programmers frequently experience unexpected behavior, and the benefits of programming in this paradigm are wholly unclear.

We define lambda-react-hook, a core calculus that captures the essence of hook-indexed state, and give it a type system to statically rule out unexpected behavior. We then translate lambda-react-hook into a calculus lambda-react-ref based on ML-style references, and prove that this translation preserves typability and semantics, thus showing that hook-indexed state is expressible in terms of standard references. The translation is local and admits a compositional definition, but involves significant code duplication. As well as illuminating the essence of state in React, our observations can inform the design of future reactive programming systems.