Skip to content

useInfiniteQuery: changing the key should create a new cache entry #258

@razbakov

Description

@razbakov

Changing the key should create a new cache entry that cumulates new pages.

Modifying the queryParam does reactively set data to the cached value or trigger query() and merge() in case of cache-miss. However, as the pages variable is shared between all merge calls, queried data from all queryParams are mixed.

Here is a small playground to illustrate the issue. Try triggering few loadMore with queryParam = 'a' and switch it to 'b' and load some extra data.

Ideally, the query function would have access to the current cached data (e.g. in the context argument). Thus, the merge function would receive the accumulated pages of the current key.

Originally posted by @VianneyRousset in #178

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞 bugthis isn't working as expected

    Projects

    Status

    🆕 Triaging

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions