You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lets say I have a very large comment list (around 5-10k comments). I want an infinite list that contains all comments, and updates the comments if some of them change or a comment is added/deleted.
I have two components: CommentsList - FlatList that contains all comments CommentItem - Comment component that observes a single comment
The simplest solution
The simplest solution is to wrap CommentsList with an observer observing all comments, then whenever a comment is added/deleted, we update the comments list with the correct comments. This would work but since we have a very large amount of comments this would be slow.
Paginate without observer
Instead of wrapping CommentsLists with an observer, we add a state of loaded comments, and each time we reach the end of the list, we query with skip and take and append the result to the comments state. This will query much faster, but means that list might not always be updated in the case of a comment being deleted or added after we queried it.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Lets say I have a very large comment list (around 5-10k comments). I want an infinite list that contains all comments, and updates the comments if some of them change or a comment is added/deleted.
I have two components:
CommentsList
- FlatList that contains all commentsCommentItem
- Comment component that observes a single commentThe simplest solution
The simplest solution is to wrap
CommentsList
with an observer observing all comments, then whenever a comment is added/deleted, we update the comments list with the correct comments. This would work but since we have a very large amount of comments this would be slow.Paginate without observer
Instead of wrapping
CommentsLists
with an observer, we add a state of loaded comments, and each time we reach the end of the list, we query with skip and take and append the result to the comments state. This will query much faster, but means that list might not always be updated in the case of a comment being deleted or added after we queried it.Beta Was this translation helpful? Give feedback.
All reactions