Solutionunvalidated

Keep the latest sequence in a mutable ref and have all pointer handlers read from `sequenceRef.current` instead of a captured state value. Update `sequenceRef.current` via a `useEffect` whenever the sequence changes, while registering handlers once (and/or recreating them only based on the ref, not the state).

9ef6be4d-1973-472e-b9fd-9f3242653f3e

Keep the latest sequence in a mutable ref and have all pointer handlers read from sequenceRef.current instead of a captured state value. Update sequenceRef.current via a useEffect whenever the sequence changes, while registering handlers once (and/or recreating them only based on the ref, not the state).