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

182
Visualizações
What is the correct typescript type for the function

I just started with the TS .What class should I set for the onGetData in the interface. Because as I know, any cannot be left in the code

interface Props {
  onGetData: any;
}

class TSSS extends Component<Props> {
  componentDidMount() {
    this.props.onGetData();
  }

  render() {
    return <div></div>;
  }
}

export default connect((dispatch: any) => ({
  onGetData: () => {
    dispatch(getUsersData());
  },
}))(TSSS);

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

maybe you can use : Function as the type in interface so the code will be:

interface Props {
  onGetData: Function;
}

class TSSS extends Component<Props> {
  componentDidMount() {
    this.props.onGetData();
  }

  render() {
    return <div></div>;
  }
}

export default connect((dispatch: any) => ({
  onGetData: () => {
    dispatch(getUsersData());
  },
}))(TSSS);

or, if you are using visual studio code, you can hover into your function onGetData to see what the type data of the function is, and select that copy and paste into your interface Props of onGetData

about 4 years ago · Juan Pablo Isaza 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