Hello, I have been working on the Drum Machine project, I got something working (thanks to other projects) but there’s one part of code I don’t quite get.
(my solution: here
The function that get’s called the button get’s clicked uses code like this:
handleButtonClick(key, song) {
return() => { document.getElementById(key).play();
this.setState({
display: song,
});}
}
Where I expected that this would work:
handleButtonClick(key, song) {
document.getElementById(key).play();
this.setState({
display: song,
})
}
But this code tells me: document.getElementById… is null.
I really can’t see why this doesn’t work.
Thanks in advance anyway.