Skip to content

Cached initialData (function) values are not reused within staleTime window #4415

@arackaf

Description

@arackaf

Describe the bug

When initialData is specified with a function, it prevents cached data from being reused (repro below).

Your minimal, reproducible example

https://stackblitz.com/edit/vitejs-vite-rayu8t?file=src%2FApp.tsx,src%2FTodos.tsx,package.json

Steps to reproduce

Refresh the repo.

Quickly select "High" from the dropdown.

The results will change.

Quickly re-select "All."

The cached "All" results will not re-show.

Expected behavior

The cached data should be re-used within the staleTime window.

How often does this bug happen?

Every time

Screenshots or Videos

n/a

Platform

MacOS / Chrome

react-query version

4.13.5

TypeScript version

n/a

Additional context

n/a

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