Search code examples
reactjsreact-nativereduxreact-reduxrtk-query

RTK Query - How to implement inifinit scrolling and concatenate query results when using the pagination function?


I am trying to implement an inifinit scroll in my React Native application. My idea is to use a FlatList and when I reach the end of the list, the Page State is incremented so that Redux RTK refetches the new data.

However, the problem is when Redux RTK refetches, the new query data response overwrites the existing data state, and I don't know if there's a way or even a boolean to eventually disable this behavior, so it would basically concatenate the query results because otherwise I'd just replace the 30 images, but I actually want to show an additional 30 images.

I would be glad to hear about possible solutions!

enter image description here

enter image description here


Solution

  • Since version 1.9 of RTK you can now use the merge option for this kind of behaviour.

    For more information you can check my answer to another question.