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

193
Views
TypeError: no se pueden leer las propiedades de nulo cuando agrego una interfaz para resolver el error de propiedad de solo lectura

Tengo esto:

 interface State { backgroundColor: boolean; isLoading: boolean; errorOccured: boolean; acknowledgment: string; } export class GoodIntention extends React.Component<Props, State> { ... onClickOfAgreement = (policy: string) => () => { this.setState({backgroundColor: true}); ... } render() { return( ... <table className={'checkbox-table ' + this.state.backgroundColor}> <label> <input className="checkbox-round" type="checkbox" onClick={this.onClickOfAgreement(policy)}/> &nbsp;&nbsp; Agree and access my certificate and disc </label> </table> ... }

Cuando ejecuto mi aplicación, el navegador da este error:

TypeError: no se pueden leer las propiedades de nulo (leyendo 'backgroundColor')

en línea <table className={'checkbox-table ' + this.state.backgroundColor}> .

Agregué la interfaz de State para resolver una Property 'backgroundColor' does not exist on type 'Readonly<{}>' basado en esto . Aunque parece que me falta algo. ¿Alguien puede aconsejar qué es eso?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

setState está en la función onClickOfAgreement. backgroundColor no existe hasta la primera vez que el usuario hace clic.

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!