Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
Cómo extender correctamente el componente de clase en react typescript

Estoy tratando de convertir el código jsx actual a mecanografiado. El problema es con el componente de clase y extenderlo.

Ejemplo:

export default class ViewComponent<P, S> extends React.Component<P & IViewComponentProps, S> {}

export default class UIComponent<P, S> extends ViewComponent<P & IUIComponentProps, S & IUIComponentState> {}

export default class BasePopover<P, S> extends UIComponent<IBasePopoverProps, IBasePopoverState> {}

Recibo un error de mecanografiado en UIComponent, cuando inicializo this.state - TS2322: Type '{ hovered: false; enfocado: falso; visible: verdadero; }' no se puede asignar al tipo 'Readonly.

Traté de cambiar UIComponent a

export default class UIComponent<P, S> extends ViewComponent<IUIComponentProps,IUIComponentState> {}

y luego tengo un error en BasePopover TS2339: la propiedad 'datos' no existe en el tipo 'Readonly & Readonly{ children?: ReactNode; }>'

Este es un código de ejemplo en github: https://github.com/Husamoa/typescript-extends-component

¿Cómo hacer esto correctamente en react typescript?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!