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

148
Views
¿Alguna idea de cómo rastrear un aumento dinámico de altura de div durante una iteración?

¿Alguna idea de cómo rastrear un aumento dinámico de altura div durante una iteración? mi problema aquí es que obtengo la altura total de los elementos en lugar de que la altura aumente en cada iteración.

 {items.map((item) => { if (document.getElementById('divtotrack')) { let clientHeight = document.getElementById('divtotrack')!.clientHeight; } return ( <div> <item key={item.id} id={item.id} content={item.content} /> </div> ); })} </div> </div>

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

0

cuando está renderizando, el componente existe solo en el DOM virtual, después de la fase de reconciliación se sincroniza con el DOM del navegador, por lo que en el momento en que está mapeando lo más probable es que no lo encuentre en el DOM. Para hacer lo que desea, debe implementar su lógica dentro del componente del elemento (tenga en cuenta que debe nombrarse en mayúsculas para que se reconozca como un JSX válido)

dentro del componente del elemento, cree una variable de ref y adjúntela al elemento principal.

 const itemRef = useRef(); useEffect(() => { if(itemRef.current) { const height = itemRef.current.clientHeight; ...do what you need here. If you need to change any of the ref div attributes use a state variable. } }, [itemRef.current] return ( <div ref={itemRef}>....</div> )

Si desea usar MutationObserver, hágalo dentro de useEffect o use un enlace personalizado o uno existente (solo busque useMutationObserver)

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!