Is there a solution for using MusicKitJS in ReactJS?

I'm trying to use MusicKitJS inside my ReactJS web app and I tried to do some tricks that usually work with non-react libraries, but in MusicKitJS's situation it for some reason drops a lot of frames and make the entire web app lag so much that it's almost unusable..


I'm writing here to see if someone has a good solid solution / trick on how to implement and use MusicKit in ReactJS with good performance...


Replies

I found the problem, now I need to find the solution...

For some reason when the audio is playing MusicKit is spamming API calls for something called "universal-activity-service", it doesn't happen on my other project where I use plain JS, but for some reason it does happen in ReactJS...

I'd love to know if someone has a clue on how to prevent the API calls spam...

EDIT:

Found the solution... I had a test script accidentally still in the project..

The test script checked in the timeDidChange event if the audio should and is playing and if it should and isn't it'd start playing (and it's playing and shouldn't it'd pause it), and because it was a test script that shoulda been deleted it tried to compare boolean to undefined which is always false which mean that every timeDidChange callback (approx. once per second) it executed music.player.play() which then executed the "universal-activity-service" API calls which is probably for MusicKit's server to keep track on the user's playback state... and that's why there was an API call spam