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

160
Views
No obtener el ancho/alto actualizado al volver a renderizar

Por favor revise el fragmento a continuación. Los elementos anidados dentro de div cambian y se vuelven a renderizar (administrados por estado) y, en consecuencia, cambia la altura de div . Pero no obtengo la altura/ancho más duradero de la etiqueta div . Da la altura/anchura anterior (una renderización detrás).

¿Alguna idea, cómo obtener el ancho/alto más actualizado de div en cada renderizado?

¡Gracias!

 import { useRef, useEffect } from "react"; const Component = (props) => { const willMount = useRef(true); const y = useRef(); // const [width, height] = useWindowSize(); useLayoutEffect(() => { console.log("helloUseLayout"); console.log(y.current.offsetWidth); console.log(y.current.offsetHeight); }); useEffect(() => { if (willMount.current) { //... } willMount.current = false; console.log(y.current.offsetWidth); console.log(y.current.offsetHeight); }); return ( <div ref={y} style={{height: "300px", overflow: "auto" }}> // Other Nested Components... // causing overflow and thus creating Y-Scrollbar. </div> ); }; export default Component;

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!