I just finished the base of the drum machine project and wanted some input on accessing html tags
Currently I am doing this type of way which seems to work with no issue.
handleClick(e) {
e.target.children[0].play();
this.setState({
displayText: e.target.id
});
handleKeyPress(e) {
const checkLetter = /[QWEASDZXC]/.test(e.key.toUpperCase());
if (checkLetter && !this.state.fired) {
const key = "#" + e.key.toUpperCase();
const element = document.querySelector(key);
element.play();
this.setState({
fired: true,
displayText: element.parentElement.id
});
}
}
However, when researching how to do it references came up and they seem very redundant for something of this scale.