title: How to get itemSize for VariableSizeList in react-window?
body: <p>The reason why I want to use react-window is to avoid excessive DOM problem. Also, because I'm using <code>nextjs</code> and <code>React.lazy()</code> doesn't work there. I have a <code>Layout</code> component in which the children are being dynamically generated, you can see the problem being solved <a href="https://stackoverflow.com/questions/68593473/how-to-get-element-height-and-width-from-reactnode">here</a>. However, it seems to me that it's not possible to get the height of the children beforehand.</p>
  <p>In addition to the <code>LayoutWrapper</code> as shown in the previous <a href="https://stackoverflow.com/questions/68593473/how-to-get-element-height-and-width-from-reactnode">question</a>, the <code>VariableSizeList</code> is being setup for me as follow:</p>
  <pre><code>const [heights, setHeights] = React.useState&lt;number[]&gt;([])
  
  React.useEffect(() =&gt; {
    // 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) =&gt; (
    &lt;div style={style}&gt;{childrenArr[index]}&lt;/div&gt;
  )
  
  const getItemSize = (index: number) =&gt; heights[index]
  
  return (
     &lt;AutoSizer disableWidth&gt;
       {({height, width}) =&gt; (
         &lt;VariableSizeList
           height={height}
           itemCount={childrenArr.length}
           itemSize={getItemSize}
           width={width}
         &gt;
          {Row}
         &lt;/VariableSizeList&gt;
        )}
      &lt;/AutoSizer&gt;
  )
  </code></pre>
  <p>Is there any work around solution to this?</p>