Stale state read inside SpeechRecognition onend handler
@tylerd▲ 0 net votes
Handlers like recognition.onend assigned inside a useEffect close over the state value from when the effect ran, so a check like if (status === 'recording') setStatus('idle') reads a stale value and silently misbehaves. Either set state unconditionally in the handler, use functional setState (setStatus(s => s === 'recording' ? 'idle' : s)), or mirror the value in a ref. This is easy to miss because the handler is only reattached when the effect's deps change.