I have a react-virtualized's infinite scroll list, (Most of the setup is copied from this example). I'm providing it with a rowRenderer
function like the specs requires. this works fine if the rowRenderer
function is very lightweight (i.e returns a very basic component as row).
but the rendering of my RowComponent
includes some Array.map
over some properties. this shouldn't cause any problem except that the rowRenderer
functions is being called tens or even hundreds of times while scrolling. this causes a performance issue, making the scroll not smooth enough.
So far I tried:
- Caching my
rowRenderer
this works, but I don't like this solution as it may cause problems in the future. - Make my
RowComponent
's render function pure and implementshouldComponentUpdate
usingreact-addons-shallow-compare
. this slightly improved the performance but not enough.
In this example, the rowRenderer
function is also being called many times per scroll (no perf issues there as the function is very lightweight), which makes me believe this behavior is by design. so:
Is caching a good solution? any advice in how to sync it with my app's state (I use redux for state management)? is there something I missed in the docs that can reduce calls to rowRenderer
(there's no reason for my rows to change while scrolling)?