Code Monkey home page Code Monkey logo

Comments (3)

TkDodo avatar TkDodo commented on June 8, 2024

we only call the getNextPageParam function after we've already successfully fetched at least one page, so the access you're showing is safe. Also, we have tests for this.

the place your stacktrace points to comes likely from here:

export function hasNextPage(
options: InfiniteQueryPageParamsOptions<any, any>,
data?: InfiniteData<unknown>,
): boolean {
if (!data) return false
return getNextPageParam(options, data) != null
}

so I think you wind up with corrupted data in your cache, e.g. an empty array that doesn't conform to the InfiniteData type structure. This should be trivial to debug by looking into the query devtools or by setting a logpoint / breakpoint at the location where the error occurs.

one wild guess is that you call setQueryData on this entry, or have a global intitialData that gets applied and puts the wrong structure in the cache. This is as far as my guesswork goes without seeing a proper reproduction. If you file another issue about this without showing a reproduction, I will close it without comment.

from query.

meotimdihia avatar meotimdihia commented on June 8, 2024

I have this problem today. It occured because the queryKey is the same as another query ( not an infinite one)

from query.

TkDodo avatar TkDodo commented on June 8, 2024

keys need to be unique, see: https://tkdodo.eu/blog/effective-react-query-keys#caching-data

from query.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.