Ability to pass a render function for an item
See original GitHub issuereact-virtualized takes a rowRenderer
prop, and FlatList
in react native takes a similar renderItem
prop. What is the reason you chose to go with an API where you pass a component as a child instead?
Doing so forces you to go through this memoization process if you want to pass props down to the item. I would think this is an extremely common use case, and if you accept a render function instead we can pass down any props we want as normal props, allowing the user to leverage any of React’s builtin checks for sCU (PureComponent
, React.memo
).
Would you be open to expanding the API a bit? Instead of passing a component as a child, we could instead provide two different props: itemComponent
and renderItem
, the former just passed a component (like now) and the latter passes the data into a function which returns a component.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:31 (14 by maintainers)
Top GitHub Comments
Thanks for taking the time to respond so thoroughly!
In the past 24 hours, I’ve chatted with Spencer about React Native’s
FlatList
, Necolas about Twitter’s virtualization, and you here– and I’m getting my threads mixed up a bit at this point, but…If you come up with a concrete suggested change to
react-window
(or even if you have one now) pitch it here as a comment, let me sit and think on it a bit, and see if we can’t come up with a compromise that would address your concerns.I’m not actually using my windowing components very much these days, so it’s easy for me to get hung up on theoretical usage that’s out of touch. I appreciate the feedback from people who have used them a lot.
I think your original suggestion has been to provide a plain function render option rather than a component. If that’s still your primary suggestion, then what would your proposed API be like given that I definitely want to continue treating item renderers as React elements by default.