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

162
Views
¿Cómo se enfocan los elementos de la matriz ocultos en Display Flex Overflow en React?

Si tengo una matriz como esta:

 let arr = [ { color: 'blue', size: '12' }, { color: 'red', size: '12' }, { color: 'green', size: '13' }, ]

Representado así en React (con useRef para marcar todos esos elementos):

 import React, { useRef } from 'react' const ExampleComponent = () => { var cardRef = useRef([]) return ( <div style={{ maxWidth: '50vw', overflowX: 'auto' }}> <ul className="d-flex" style={{ listStyle: 'none' }}> { arr.map( ( obj, id ) => { return( <div key={ id } ref={ el => cardRef.current[ id ] = el } className="card" style={{ width: '55vw', height: '20vh' }}> <div><p>color: { obj.color }</p></div> <div><p>size: { obj.size }</p></div> </div> ) })} </ul> </div> ) }

¿Cómo puedo hacer que un botón como el de abajo se centre en el último elemento de color green y tamaño 13 ?

 <button onClick={ e => { e.preventDefault() sourceRef.current[ 2 ].focus() }} className="btn btn-sm btn-info"> Focus Source 1 </button>

Solo pregunto porque esperaba que al hacer clic en ese botón hiciera que el último elemento se desplazara a la vista, pero no fue así.

¿Cómo puedo hacer que el último elemento se desplace a la vista?

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!