Recommended pattern for a grid of dynamic, but uniformly-sized items? #732
Unanswered
matthewhuang97
asked this question in
Q&A
Replies: 1 comment 1 reply
-
would this help? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there, thanks for this library! Our team has a use case where we...
We currently have a setup with TanStack virtual where we:
lanes
option by measuring & computing how many items fit on each rowestimateSize
option(looks a bit like this)
This mostly works well, except the computed value of
virtualizer.getTotalSize()
is incorrect. It seems to be using stale values ofestimateSize
to compute the measurement of each item instead of the values we update in state during resizing.The reason we're not doing fully-dynamic measurements as per the docs, is because it seemed like overkill. We know all our items are the same height, so we could avoid any performance hits by just measuring the first item, and then telling the virtualizer that all of our items are of this size. Maybe this optimization isn't actually useful though, and would love someone with more familiarity here to let me know if that's the case!
It seems to me like perhaps my mental model of
estimateSize
is incorrect. I thought it would update reactively if the value was changed, but it looks like it's only used initially to do the first layout (especially if dynamic measurements aren't supplied).Does anyone have guidance on the best patterns to support our use case? Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions