GetStream / react-native-bidirectional-infinite-scroll

📜 React Native - Bidirectional Infinite Smooth Scroll
https://getstream.github.io/react-native-bidirectional-infinite-scroll/
MIT License
236 stars 27 forks source link

Decrease number of re-renders on renderItem #2

Closed CarlosRafael22 closed 3 years ago

CarlosRafael22 commented 3 years ago

I was trying to decrease the number of re-renders when items where added to the list after onStartReached or onEndReached were called. There were unecessary re-renders of already created items (at least in my view, maybe there is a reasoning for that), so I wanted only new items to call the renderItem prop passed to the Flatlist and improve the list rendering.

For that, I proposed a PR #1 using React.memo and React.useCallback to memoize the already rendered items and only call the renderItem to the new items on the list. Hope it'll be helpful somehow.

vishalnarkhede commented 3 years ago

This should be handled by end user by adding memoization as per app requirements around renderItem :)

CarlosRafael22 commented 3 years ago

Yeah, it was way easier to just wrap the renderItem with the React.memo haha Thanks for the feedback :)