I have an error:
Property 'innerText' does not exist on type 'EventTarget'.
I'm trying to add event listener and get value from element. Everything works fine but this error shows up in console .
public componentDidMount() {
const element = document.querySelector(".mdc-list")
element.addEventListener("click", (e) => {
this.data.menu.title = e.target.innerText
})
}
Window
is possibleEventTarget
and it doesn't haveinnerText
. AlsoDocument
. You need to check whichEventTarget
was it. – Roberto Zvjerkovićconsole.log(e.target.nodeName)
outputs? – Mamunthis.data.menu.title = e.target.value
– Monica Acha