Просмотр исходного кода

fix audio not working during development due to react's useEffect wil be triggered twice (#6126)

Lance Mao 9 месяцев назад
Родитель
Сommit
75445a0c66
1 измененных файлов с 4 добавлено и 0 удалено
  1. 4 0
      web/app/components/base/voice-input/index.tsx

+ 4 - 0
web/app/components/base/voice-input/index.tsx

@@ -152,6 +152,10 @@ const VoiceInput = ({
   useEffect(() => {
     initCanvas()
     handleStartRecord()
+    const recorderRef = recorder?.current
+    return () => {
+      recorderRef?.stop()
+    }
   }, [])
 
   const minutes = parseInt(`${parseInt(`${originDuration}`) / 60}`)