Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

182
Vistas
How to get itemSize for VariableSizeList in react-window?

The reason why I want to use react-window is to avoid excessive DOM problem. Also, because I'm using nextjs and React.lazy() doesn't work there. I have a Layout component in which the children are being dynamically generated, you can see the problem being solved here. However, it seems to me that it's not possible to get the height of the children beforehand.

In addition to the LayoutWrapper as shown in the previous question, the VariableSizeList is being setup for me as follow:

const [heights, setHeights] = React.useState<number[]>([])

React.useEffect(() => {
  // This will actually returns [] which I don't want to happen.
  // I want it to return an array of heights
  const data = onMount()
  setHeights(data)
}, [onMount])

const Row = ({index, style}: ListChildComponentProps) => (
  <div style={style}>{childrenArr[index]}</div>
)

const getItemSize = (index: number) => heights[index]

return (
   <AutoSizer disableWidth>
     {({height, width}) => (
       <VariableSizeList
         height={height}
         itemCount={childrenArr.length}
         itemSize={getItemSize}
         width={width}
       >
        {Row}
       </VariableSizeList>
      )}
    </AutoSizer>
)

Is there any work around solution to this?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda