Skip to content

Consider cleaning up the appended Spotify SDK script element and removing event listeners during component unmount to prevent potential memory leaks. #136

@Guliveer

Description

@Guliveer

Consider cleaning up the appended Spotify SDK script element and removing event listeners during component unmount to prevent potential memory leaks.

        };

        return () => {
            // Remove the script from the DOM
            if (script && script.parentNode) {
                script.parentNode.removeChild(script);
            }

            // Cleanup Spotify.Player instance
            const player = playerRef.current;
            if (player) {
                player.disconnect();
                player.removeListener("ready");
                player.removeListener("not_ready");
            }

            // Remove global event listener
            window.onSpotifyWebPlaybackSDKReady = null;
        };

Originally posted by @Copilot in #130 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprovement of existing feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions