From 89b828a576cb36d05abb24e71be4367cfa8e7467 Mon Sep 17 00:00:00 2001 From: Arjun Patel Date: Mon, 1 Jun 2026 17:30:27 -0700 Subject: [PATCH] nit --- js/desktop/src/hooks/use-stream-playback.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/js/desktop/src/hooks/use-stream-playback.ts b/js/desktop/src/hooks/use-stream-playback.ts index 14ce19c..a9b8c2b 100644 --- a/js/desktop/src/hooks/use-stream-playback.ts +++ b/js/desktop/src/hooks/use-stream-playback.ts @@ -106,9 +106,11 @@ export function useStreamPlayback( const [state, dispatch] = useReducer(playbackReducer, initialState); // Track the stream ID we've initialized for, to reset when navigating between streams const initializedForRef = useRef(null); - // Latest currentIndex for onParticleRemoved (passed to the subscription), so - // it reads the current value without re-subscribing. useEffectEvent can't be - // used — it may not be passed to another hook. + // Latest currentIndex for onParticleRemoved, which is passed into + // useLiveParticleChildren. Reading it through a ref keeps the callback stable + // (no re-subscription) and breaks the declaration cycle + // children -> currentIndex -> callback -> children. useEffectEvent can't be + // used here — Effect Events may not be passed to another hook. const currentIndexRef = useRef(0); // --- Firestore change callbacks --- @@ -147,7 +149,7 @@ export function useStreamPlayback( const currentParticle = currentIndex !== -1 ? children[currentIndex] : null; - // Keep the latest-index ref in sync for onParticleRemoved (above). + // Keep the ref read by onParticleRemoved in sync with the derived index. useEffect(() => { currentIndexRef.current = currentIndex; }, [currentIndex]);