patterntypescriptreactCritical
Why is the React `MouseEvent` in the checkbox event handler not generic?
Viewed 0 times
handlereventwhythereactnotcheckboxgenericmouseevent
Problem
I have an checkbox TSX(JSX) element:
With the help of VS code I know that the input parameter type of the
Then I get an error saying
Version of my packages:
Why is that?
With the help of VS code I know that the input parameter type of the
this.handleCheckboxClick is MouseEvent. So I implemented it with:private handleCheckboxClick(event: MouseEvent) {
...
}Then I get an error saying
[ts] Type 'MouseEvent' is not generic. As shown in the image below:Version of my packages:
"@types/react": "^15.0.29",
"@types/react-dom": "^15.5.0",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"typescript": "^2.3.4",Why is that?
Solution
You're probably using the DOM
MouseEvent. Try using React.MouseEvent instead.Context
Stack Overflow Q#44764146, score: 572
Revisions (0)
No revisions yet.