-
-
Notifications
You must be signed in to change notification settings - Fork 393
Description
Ran into an issue with images inside the dynamic rows.
Images are rendered as placeholders first. When the asset is loaded, the image component is re-rendered to correct dimensions. However, as the image component is a child of the virtual row, the row and the virtualizer are unaware of the size change.
This causes either a larger-than-intended gap between the elements, or an overlap.
I was able to mitigate it by
- Saving the row container node (same that is attached to
measureRef) to a separate ref. - Drilling down an
onLoadcallback prop - Calling
measureRefmanually with the node saved on step 1 insideonLoad.
It feels a bit cumbersome though. I wonder if this could be resolved inside the library, e.g. by having a resize observer on select nodes. In DIY testing of that idea without touching the library code though I ran into lots of re-rendering that decimated the performance.
I understand that maybe there is no good one-size-fits-all solution for this. In this case, maybe we could at least improve the ergonomics of re-measuring individual rows somehow.
Or maybe there is a way to handle this case already and I'm just unaware of it. keyExtractor doesn't seem to be the solution here because nothing about the row itself changes.