Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

837
Visualizações
Why is the `MouseEvent` in the checkbox event handler not generic?

I have an checkbox TSX(JSX) element:

<input type="checkbox" name={i.toString()} onClick={this.handleCheckboxClick} />

With the help of VS code I know that the input parameter type of the this.handleCheckboxClick is MouseEvent<HTMLInputElement>. So I implemented it with:

private handleCheckboxClick(event: MouseEvent<HTMLInputElement>) {
    ...
}

Then I get an error saying [ts] Type 'MouseEvent' is not generic. As shown in the image below:

enter image description here

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?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

You're probably using the DOM MouseEvent. Try using React.MouseEvent<HTMLInputElement> instead.

over 4 years ago · Santiago Trujillo Relatório

0

In order to use React MouseEvent just make sure to add:

import { MouseEvent } from 'react';
over 4 years ago · Santiago Trujillo Relatório

0

You can use SyntheticEvent instead of MouseEvent

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda