Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

177
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda