The open-source CapCut alternative
formatting
Maze Winthere4546120008b
diff --git a/apps/web/src/components/editor/audio-waveform.tsx b/apps/web/src/components/editor/audio-waveform.tsxindex 372a31c5..79bf401d 100644--- a/apps/web/src/components/editor/audio-waveform.tsx+++ b/apps/web/src/components/editor/audio-waveform.tsx@@ -20,7 +20,7 @@ const AudioWaveform: React.FC<AudioWaveformProps> = ({useEffect(() => {let mounted = true;let ws = wavesurfer.current;-+const initWaveSurfer = async () => {if (!waveformRef.current || !audioUrl) return;@@ -90,7 +90,7 @@ const AudioWaveform: React.FC<AudioWaveformProps> = ({const wsToDestroy = ws;// Detach from ref immediatelywavesurfer.current = null;-+// Wait a tick to destroy so any pending operations can completerequestAnimationFrame(() => {try {@@ -111,13 +111,13 @@ const AudioWaveform: React.FC<AudioWaveformProps> = ({return () => {// Mark component as unmountedmounted = false;-+// Store reference to current wavesurfer instanceconst wsToDestroy = wavesurfer.current;-+// Immediately clear the ref to prevent accessing it after unmountwavesurfer.current = null;-+// If we have an instance to clean up, do it safelyif (wsToDestroy) {// Delay destruction to avoid race conditions