Skip to content

Dynamic rows with children that change size post-render are not re-measured #251

@khovansky-al

Description

@khovansky-al

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

  1. Saving the row container node (same that is attached to measureRef) to a separate ref.
  2. Drilling down an onLoad callback prop
  3. Calling measureRef manually with the node saved on step 1 inside onLoad.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions