Kaynağa Gözat

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

Lance Mao 1 yıl önce
ebeveyn
işleme
75445a0c66

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

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