Skip to content

Partial Reloads no longer work as documented in Inertia 2.0 - Unlisted breaking change #701

@ncphillips

Description

@ncphillips

We have some pages that do partial reloads so we don't unmount certain parts of our UI.

For example, courses have many assignments. If we're switching from assignment to assignment we want to avoid reloading the course data.

function show($courseId, $assignmentId)
{
    return inertia('Assignment/Show', [
        'course' => fn() => Course::find($courseId),
        'assignment' => Assignment::find($assignmentId),
    ]);
}

In the Assignment/Show template we have a link using Ziggy:

<Link :href="route('courses.assignments.edit', { course: course.id, assignment: assignment.id })>Edit</Edit>

According to the docs course will always be sent on first request, but if the only prop is sent than it would be left out.

This works in Inertia 1.0

With the upgrade to 2.0 this stops working. Ziggy explodes telling me that course is undefined.

When I log out props.course then I see that the course is an empty proxy:
image

It seems to me like Inertia is now treating:

'course' => fn() => Course::find($courseId)

like this

'course' => Inertia::lazy(fn () => Course::find($courseId))

It's not the end of the world, but is a bit annoying.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions