I got a little bit of code that i can't quite wrap my head around. It's for a function that handles an onClick event in javascript/react:
handleButtonClick(key, song) {
return () => {
document.getElementById(key).play();
this.setState({
currentSongText: song,
});
};
}
Now I don't get why it does return () =>{} inside the body of handleButtonClick, but if I remove it, the code no longer works? I found nothing while googling this so any advice is welcome.
link to the project: https://codepen.io/koffiekan/pen/eYJqdWW