Skip to content
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

Decrease number of re-renders on renderItem #2

Closed
CarlosRafael22 opened this issue Feb 24, 2021 · 2 comments
Closed

Decrease number of re-renders on renderItem #2

CarlosRafael22 opened this issue Feb 24, 2021 · 2 comments

Comments

@CarlosRafael22
Copy link

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.

@CarlosRafael22 CarlosRafael22 changed the title Decrease the number of re-renders of items in the list when adding new ones Decrease number of re-renders on renderItem Feb 24, 2021
@vishalnarkhede
Copy link
Collaborator

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

@CarlosRafael22
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants