diff --git a/src/LiveAudioVisualizer/LiveAudioVisualizer.tsx b/src/LiveAudioVisualizer/LiveAudioVisualizer.tsx index 3d7def2..d12cd09 100644 --- a/src/LiveAudioVisualizer/LiveAudioVisualizer.tsx +++ b/src/LiveAudioVisualizer/LiveAudioVisualizer.tsx @@ -132,8 +132,10 @@ const LiveAudioVisualizer: (props: Props) => ReactElement = ({ }, [analyser, context.state]); useEffect(() => { - if (context.state !== "closed") { - context.close(); + return () => { + if (context.state !== "closed") { + context.close(); + } } }, []);