Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: n.get() is undefined when trying to prefetch with the router #2053

Open
nick-potts opened this issue Oct 22, 2024 · 0 comments · May be fixed by #2100
Open

TypeError: n.get() is undefined when trying to prefetch with the router #2053

nick-potts opened this issue Oct 22, 2024 · 0 comments · May be fixed by #2100

Comments

@nick-potts
Copy link
Contributor

nick-potts commented Oct 22, 2024

Versions:

  • @inertiajs/core version: beta.2
  • @inertiajs/react version: beta.2

Describe the problem:

From a layout, I'm trying to call prefetch programmatically but it results in an error.

useEffect(() => {
      router.prefetch(
          "/users",
          { method: "get", data: { page: 2 } },
          { cacheFor: "1m" }
      );
}, []);
Uncaught (in promise) TypeError: n.get() is undefined
    getHeaders request.ts:137
    send request.ts:49
    send requestStream.ts:18
    prefetch router.ts:220
    v prefetched.ts:36
    add prefetched.ts:35
    prefetch router.ts:217
    default DefaultLayout.tsx:23
    default DefaultLayout.tsx:22
    React 13
    workLoop scheduler.development.js:266
    flushWork scheduler.development.js:239
    performWorkUntilDeadline scheduler.development.js:533
    scheduler chunk-QANAYWAR.js:405
    scheduler chunk-QANAYWAR.js:453
    __require chunk-WOOG5QLI.js:12
    scheduler chunk-QANAYWAR.js:465
    __require chunk-WOOG5QLI.js:12
    React 2
    __require chunk-WOOG5QLI.js:12
    dom React
    __require chunk-WOOG5QLI.js:12
    dom React
    __require chunk-WOOG5QLI.js:12
    <anonymous> react-dom_client.js:38 
    ```
@joetannenbaum joetannenbaum linked a pull request Nov 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant