-
-
Notifications
You must be signed in to change notification settings - Fork 398
Description
Bug Report
I'm experiencing a bug, where when having an empty list (ie. size parameter in useVirtual is 0), the returned virtualRow array still contains a single element. That single element is "empty", as it is an object that only contains a measureRef key, and none of the other keys (index, start, end, size).
Reproduction
I've created a minimal reproduction of the issue at https://codesandbox.io/s/amazing-glade-eo7vw?file=/src/index.js which is a fork of the "Dynamic Rows" example. It starts off with having an empty list, and then after 5 seconds, changes the list to have items. The console log (and the error) shows that we start with an empty virtualRow, and then get correct virtualRows after 5 seconds.
What should happen instead, is that no console logs are present in the beginning, because the virtualRows array should be empty.
Context
I believe this bug was introduced in version 2.2.4 by #48. Downgrading to version 2.2.3 "fixes" the issue. But as the changes in that PR are rather substantial, I haven't been able to pinpoint exactly where the problem is. Pinging @mogelbrod
This might be the same bug as #49.
Workaround
Current workarounds are:
- downgrade to version
2.2.3 - before mapping through the
virtualRows, ensure that you have at least one rawitem(and NOT just onevirtualRow), eg.
<div>
{items.length > 0 && rowVirtualizer.virtualItems.map((virtualRow) => {
...return rows
})}
</div>