Race condition with url
miracle2k opened this issue · comments
If you have the url change very quickly after the first call to useSound()
(in my case from an empty string to the real url), then the hook will keep playing the old one.
This is because useOnMount
to load howler is called with the first url
value it sees, and if loading howler completes only after I changed the url, the howler instance is created with the old url and not updated.
Sorry for the delay, I haven't had the bandwidth to focus on this project!
I've been assuming that the src is static; having it be dynamic opens up a bunch of possible issues.
If possible, I'd suggest not rendering the hook until the src is available. You'd need to move it into a little component to be able to conditionally render it.
I'm not actively working on this project so I don't imagine being able to fix this, but I encourage anyone to fork it and give it a shot!