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

183
Views
Reaccionar almacenando el estado en una variable de elemento.

Quiero saber cómo, si es posible, puedo almacenar un estado en un elemento que se almacena en una variable.

Este es mi código simplificado:

 export class DashboardLists extends Component{ constructor(props){ super(props); this.state = { listCount: 0, ... } ... this.headerLeft = <h2 style={{marginTop: "0px"}}>Lists {this.state.listCount}</h2>; ... } render(){ return( <div> ... {this.headerLeft} ... </div> ); } }

Cuando llamo a cambio de estado, el valor en el elemento no muestra el valor de estado actualizado.

Es necesario para mí almacenar el elemento en una variable, porque en mi código completo debo pasar el elemento como accesorio a otro elemento.

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

0

Eliminar headerLeft del constructor. Cree un método dedicado en la clase, algo así como getHeaderLeft() {return <h2 style={{marginTop: "0px"}}>Lists {this.state.listCount}</h2>;} y llámelo en el método de representación {this.getHeaderLeft()}

-Constantin Samarin

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!