Skip to content

[solid-query v5]: placeholderData returns wrong values when returned data is an array #5994

@skokenes

Description

@skokenes

Describe the bug

In solid-query v5, if you use placeholderData: keepPreviousData with a query that returns arrays, the cacheing breaks and returns the wrong results when returning to previously fetched queries.

See the demonstration in the attached video and codesandbox. In the codesandbox, the returned result should always match with the search property. This works fine when NOT using placeholderData. However, with placeholderData on, the query.data values seem to get out of sync with the latest query key.

Your minimal, reproducible example

https://codesandbox.io/s/solid-query-placeholder-broken-392lsq?file=/index.js

Steps to reproduce

  1. Type in "a". Notice that the correct result gets returned
  2. Type in "ac". Notice that correct result gets returned
  3. Delete "c" to return to "a", which should be cached. Notice that the query returns the wrong data

Expected behavior

When using placeholderData, the query cache should return the same values as if you weren't using placeholderData.

How often does this bug happen?

Every time

Screenshots or Videos

solid-query-placeholder-bug.mp4

Platform

OSX, Chrome

Tanstack Query adapter

None

TanStack Query version

v5 beta 23

TypeScript version

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions