-
-
Notifications
You must be signed in to change notification settings - Fork 795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
problem with getEstimatedTotalSize #31
Comments
Can you provide a repro case? Either Code Sandbox or a unit test would be fine. |
@bvaughn https://codesandbox.io/s/00mlymwvzp, I added |
I see. There are a couple of things going on here. Firstly, Your example doesn't call this method when updating the data– but it should. Your handleChange = e => {
const inputValue = e.target.value;
const data = DATA.filter(x => x.label.includes(inputValue));
// Update state with the filtered list:
this.setState({ data }, () => {
// Once state has been updated, let VariableSizeList know to clear its cached measurements:
this.listRef.current.resetAfterIndex(0);
});
}; The way you're reading the size of the Hopefully, this should be a working solution for you: https://codesandbox.io/s/mzxopv0v5p |
Thanks for your detailed explanation, I realized I should call I read the source code for |
This wouldn't work, because
This isn't really something that's intended to be done, but if you really wanted to read it– you'd have to read it after the data was updated (in your component's state) and the list re-calculated dimensions. |
So in your post about the |
BTW, I’m wondering if we could add a second param like shouldForceUpdate to leave the update to the user instead? |
Yes, I think that would be a pretty reasonable solution in this particular case, since "remeasuring" the items is fast.
Hm. This might work, but it would have some tricky edge cases. For example, if you sorted the data rather than filtering it– then the |
But the itemData changed, we should be clear when to use the param, as it defaults to true, so the change won’t beak anything, and for most cases, we would update the outter component to rerender the list, so I think that param would pretty useful |
This is true for your app (and probably most apps) but I'm not sure if it's necessarily true for every case. If you want to implement it– including adding tests, and updating docs, (and adding a similar change to |
Resolved via #32 |
I'm working on a select component with
VariableSizeList
ofreact-window
and it works perfect, but when I search to narrow down the result (and the menu's height will update), the innerRef's clientHeight is wrong asgetEstimatedTotalSize
is not works right with dynamic dataThe problem is that if the itemCount changes from 100 to 1,
lastMeasuredIndex
is larger then 1, so we can't rely on it anymoreCurrently I solved the problem by pass
key={itemCount}
toList
to make a refresh calculation. So perhaps that's not a bug, but I think we should denote that it could be problematic with dynamic dataThe text was updated successfully, but these errors were encountered: