data param on itemSize func for VariableSizeList
See original GitHub issueThanks for adding the data
param on the itemKey
func in 3c9a558.
I use the itemSize
function in my usage of VariableSizeList
, where the size of the item depends on the data in some way. It would be useful if the itemSize
function also had a data
param.
I can send a PR if you like, just wanted to run it by you first. Thanks.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:10 (5 by maintainers)
Top Results From Across the Web
(react-window) How to pass props to {Row} in <FixedSizeList ...
You can access both parameters from the function definition. So then you can pass the data directly into the Row() call. const Example...
Read more >Virtualize large lists with react-window - web.dev
Use the VariableSizeList component to render a list of items that have ... The item size function passed to the itemSize prop randomizes...
Read more >Virtualizing Large Data Lists with react-window
In this tutorial, we'll cover on how render large amount of data, ... and itemSize which takes in a function in this case...
Read more >How Does Reactwindow Variablesizelist Predetermine ...
I use the itemSize function in my usage of VariableSizeList where the size of the item depends on the data in some way.It...
Read more >react-window | Yarn - Package Manager
React components for efficiently rendering large lists and tabular data. React window works by only rendering part of a large data set (just...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mj1856 Is this solution working for you even if the items are changing over time (adding, removing)? I have exactly the same type of list and I have an issue with
itemSize
being called only once when an item is rendered for the first time.@bvaughn being new to the library I was also surprised by the lack of data prop (or just the item/row prop) as parameter for this function. I read your opinion on the matter and I just have a question if you might have time to clarify what is the best approach.
My surprise comes from the fact that this forces the usage of a closure like so:
As mentioned by others this makes the function less “movable” because it relies on and external variable
myItems
, but perhaps this is not such a strong point to complexify the library?Also, I am always worried (perhaps mistakenly, please advise) that a closure like so is redefined at each render. That causes a new function to get passed down as props and this I thought is considered a bad practice because it causes unnecessary re-renders of the child component.
Is the solution in this case to memoize the closure with a
useCallback
? Is this optimization not so necessary? Having more parameters in the library will solve this, but will perhaps just move the issue on another place causing a perf loss anyway?Thanks