fix: prevent crash from accessing released AudioRecorder ref
- use recorderState.isRecording instead of recorderRef.current.isRecording - avoid touching native shared object after it's been released - fixes production crash: 'cannot cast to AudioRecorder (received Integer)' 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -178,7 +178,7 @@ export function useAudioRecorder(config?: AudioCaptureConfig) {
|
||||
// Use configRef to access the latest callback without recreating the effect
|
||||
useEffect(() => {
|
||||
const currentConfig = configRef.current;
|
||||
if (!currentConfig?.onAudioLevel || !recorderRef.current.isRecording) return;
|
||||
if (!currentConfig?.onAudioLevel || !recorderState.isRecording) return;
|
||||
|
||||
const interval = setInterval(() => {
|
||||
const metering = recorderState.metering;
|
||||
@@ -346,8 +346,8 @@ export function useAudioRecorder(config?: AudioCaptureConfig) {
|
||||
|
||||
const isRecording = useCallback(() => {
|
||||
// Treat local intent as backup so callers can detect pending sessions
|
||||
return recorderRef.current.isRecording || recordingIntentRef.current;
|
||||
}, []);
|
||||
return Boolean(recorderState.isRecording) || recordingIntentRef.current;
|
||||
}, [recorderState.isRecording]);
|
||||
|
||||
// Return stable object using useMemo
|
||||
return useMemo(() => ({
|
||||
|
||||
Reference in New Issue
Block a user