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

119
Views
matriz de ref devuelve 0 longitud en reaccionar

Traté de hacer una matriz de ref usando la función de devolución de llamada.

 class A extends React.Component { const arr=[1,2,3,4,5]; constructor(props) { super(props); this.inputs = []; } componentDidMount() { console.log(this.inputs, this.inputs.length, this.inputs[0]) // here length of inputs is 0 and inputs[0] is undefined } render() { return( <div> arr.map((key, index) => ( <Input key={key} ref={input => this.inputs[index] = input} /> <button type="button" onClick={this.inputs[index].current.focus()}>Focus</button> //here is got error as inputs[0] is undefined ) ) </div> ; } }

Estoy enfrentando dos problemas

  • Creé la referencia dentro de la matriz, la matriz tiene múltiples referencias pero no sé cómo se formatea la matriz ya que la longitud de la matriz es 0
  • Como la longitud de la matriz es 0, no puedo llamar a la referencia usando el índice de la matriz.
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!