Skip to content

Calling router.reload at mount causes an error #2340

@DhiaBen20

Description

@DhiaBen20

inertiajs/inertia-laravel Version: "^2.0"

  • @inertiajs/react version: "^2.0.0",

Describe the problem:

I want to partially reload some data from the server only when the component mounts.

Steps to reproduce:

useEffect(() => {
  router.reload({only: [key]});
}, []);

When I navigate to this page using client-side routing (from another page), everything works fine.
However, when I do a full page refresh, I get an error and the request is not sent to the server.

Here’s the error message:

@inertiajs_react.js?v=8ed0a2f8:6373 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'component')

This is the line of code that triggers the error:

this.isPartial() && (e["X-Inertia-Partial-Component"] = s.get().component);

Metadata

Metadata

Assignees

No one assigned

    Labels

    reactRelated to the react adapter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions