Skip to content

useMutation cacheTime not work #5058

@scc02

Description

@scc02

Describe the bug

In my understanding, after setting cacheTime, the data should return the value from the previous request, rather than undefined.

Your minimal, reproducible example

https://github.com/ShiChenCong/useMutation-cacheTime-demo

Steps to reproduce

  1. reproduce repo
  2. pnpm install
  3. pnpm run dev
  4. click button
  5. log undefined
  6. log [1,2,3]
  7. click button again
  8. log undefined(this step, In my understanding, should log [1,2,3] directly)
  9. log [1,2,3]

Expected behavior

return previous value rather undefined

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

macOS

TanStack Query version

4.24.10

TypeScript version

No response

Additional context

reproduce repo https://github.com/ShiChenCong/useMutation-cacheTime-demo, and mutation did not show in the devtool too.
image

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