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

353
Views
Error de TypeScript al configurar el estado de un componente: el argumento de tipo 'X' no se puede asignar al parámetro de tipo '() => void'

Tengo un error de TypeScript al llamar a setState : ingrese la descripción de la imagen aquí

Eso es lo que estoy haciendo en realidad:

 updateRequests(requests: any, cb:Function|null = null) { this.setState( { requests: { ...this.state.requests, items: requests, loading: false, }, }, () => { if (cb) cb(); } );

Aquí hay un estado de componente:

 export interface IServersScreenState { requests: { items: []; loading: boolean; statuses: {}; page: number; lastPage: number; scrollLoading: boolean; }; }

En realidad, no entiendo por qué está sucediendo así, porque no tengo ninguna declaración en el estado, las requests deben verse como ()=>void

aquí está mi setState:

 setState<T>(...args: T[]) { if (this.__mounted__) { //@ts-expect-error spread error super.setState(...args) as $TSFixMe; } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Ha definido setState para aceptar un genérico, y luego no está completando el genérico cuando se llama. Intenta reemplazar

this.setState(

con

this.setState<IServersScreenState>(

Eso debería acercarte a seguir el tipo que has configurado.

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