$ account szhsin
This repository is a zero-dependency React library for managing CSS transitions via a controlled state machine. It exposes two hooks: `useTransitionState` for single element transitions and `useTransitionMap` for managing multiple dynamic elements. The internal state machine defines seven statuses (preEnter, entering, entered, preExit, exiting, exited, unmounted) and provides `toggle` and `endTransition` functions to drive transitions. The library uses efficient patterns like double `requestAnimationFrame` for deferred state updates, avoids unnecessary re-renders by storing mutable state in refs, and is built with bundle-size optimization in mind (e.g., single-character internal property names). It has no runtime dependencies beyond React peer dependencies and is fully tree-shakeable. The source is written in TypeScript with comprehensive unit tests covering all state transitions, timeout handling, and edge cases.