howler.js
howler.js copied to clipboard
howler.js caches event handler methods
Hi
i'm using "howler": "^2.2.3"
with react "react": "^17.0.2"
.
So far it was good but I found out that the onEnd handler gets cached and inside of the handler I can't get the updated value of my state, and whenever I try to access the state, I get the old initial value.
so I did this trick:
- I've created a mock state named songJustEnded.
- when instantiating howler constructor i do:
onend: () => setSongJustEnded(true)
- in my codes, I listen to changes of the songJustEnded using useEffect and I call my onEnd handler.
Is there any fix for this or do I have to stick to this trick