Skip to content

Commit a5012c7

Browse files
committed
Clean up event listener on unmount
1 parent ee42f1d commit a5012c7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

dotcom-rendering/src/components/LoopVideo.importable.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ export const LoopVideo = ({
104104
customPlayAudioEventName,
105105
handleCustomPlayAudioEvent,
106106
);
107+
108+
return () =>
109+
document.removeEventListener(
110+
customPlayAudioEventName,
111+
handleCustomPlayAudioEvent,
112+
);
107113
}, [uniqueId]);
108114

109115
/**

0 commit comments

Comments
 (0)