I have a for
loop to play sounds. I want to break it when clicking on a button. I'm not sure if I'm facing issues with async, rerendering ... but it doesn't work. Any ideas?
const onStart = async() => {
for (const el of playlist) {
if (breakLoop) {
break;
}
await play(el);
if (breakLoop) {
break;
}
}
}
const onStop = () => {
setBreakLoop((prev) => true);
}