🎥 Make videos programmatically with React
document what we are doing
Jonny Burger83a2da83ef31
diff --git a/packages/core/src/audio/shared-audio-tags.tsx b/packages/core/src/audio/shared-audio-tags.tsxindex fc9ad3a3c8..69edcd52dd 100644--- a/packages/core/src/audio/shared-audio-tags.tsx+++ b/packages/core/src/audio/shared-audio-tags.tsx@@ -197,12 +197,6 @@ export const SharedAudioContextProvider: React.FC<{[refs, rerenderAudios]);- const resetAudio = useCallback(() => {- takenAudios.current = new Array(numberOfAudioTags).fill(false);- audios.current = [];- rerenderAudios();- }, [numberOfAudioTags, rerenderAudios]);-const updateAudio = useCallback(({aud,@@ -262,6 +256,20 @@ export const SharedAudioContextProvider: React.FC<{updateAudio,]);+ // Fixing a bug: In React, if a component is unmounted using useInsertionEffect, then+ // the cleanup function does sometimes not work properly. That is why when we+ // are changing the composition, we reset the audio state.++ // TODO: Possibly this does not save the problem completely, since the+ // if an audio tag that is inside a sequence will also not be removed+ // from the shared audios.++ const resetAudio = useCallback(() => {+ takenAudios.current = new Array(numberOfAudioTags).fill(false);+ audios.current = [];+ rerenderAudios();+ }, [numberOfAudioTags, rerenderAudios]);+useEffect(() => {return () => {resetAudio();