Flipkart / recyclerlistview

High performance listview for React Native and web!
Apache License 2.0
5.17k stars 420 forks source link

After few rows duplication of data occurs. #732

Closed AkashGoindi closed 1 year ago

AkashGoindi commented 1 year ago

Hey, I strongly need help on something which is hard to get and explain. I have used this library earlier but this time things ain't going my way.

The list is behaving in odd manner and no idea how to resolve it. Ok, the thing is I have used this library to create a feed section in app and each feed card is quite big with text, comments, images sections etc. First 3 rows get populated and afterwards data repeats from row 1. Strange thing is that when I truncate my card and leave it only with heading and few other details then it works fine. Adding more sections to card creates this duplication issue.

Please can someone make me understand whats going bad ? One thing is for sure that data is being saved correctly thats why with less data in card everything runs smooth.

ghnsharma commented 1 year ago

Did you find any solution? I am facing the similar issue, in my feed after scroll old images and videos are being mixedup with other users account. I am not sure if this is related to buffer or not.

siddharth-kt commented 1 year ago

I guess you are storing each of your card data in your Card component local state. If yes, you can not do that with RecyclerListView. Storing data in Card component state will lead to duplicate results because RecyclerListView keeps using previously rendered Card component instead of creating new Card component.

AkashGoindi commented 1 year ago

@siddharth-kt Thanks for the solution. I was out of town so didn't get a chance to give it a shot. Tried today and it did work. I stopped setting my card to component's local state but now I ran into another issue. If I don't use local state then how would i make 'like' functionality without the setState thing. As API is being called and latest data is retrieved but state is not re-rendered resulting into no visual changes in card. Also, how to know that some key is changed in redux store, if that's the case. Any help on this?

siddharth-kt commented 1 year ago

Basically you need to update your dataProvider on Card component like press. Eg:- If there are 20 items in your RecyclerListView's dataProvider list and user press like button on Card Component at index 5 then you need to update your dataProvider list item at index 5. See : https://github.com/Flipkart/recyclerlistview/issues/432#issuecomment-553914569

AkashGoindi commented 1 year ago

Thanks for the help.