Answer the question
In order to leave comments, you need to log in
What type should you choose?
I don't know if the question is more about react or ts.
As I understand it, target in this case is a wider type and needs to be narrowed down to ensure that the element has a dataset.
What is the best way to do this?
Element click event handler method
Error:(47, 80) TS2339: Property 'dataset' does not exist on type 'EventTarget'.
Answer the question
In order to leave comments, you need to log in
Use generic for MouseEventHandler:
Where T is the type you want, including the dataset
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question