Browse Source

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

Lance Mao 9 tháng trước cách đây
mục cha
commit
75445a0c66
1 tập tin đã thay đổi với 4 bổ sung0 xóa
  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}`)