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

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

Open
ncphillips opened this issue Jan 2, 2025 · 0 comments

Comments

@ncphillips
Copy link

ncphillips commented Jan 2, 2025

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.

@ncphillips ncphillips changed the title Inertia 2.0 unlisted breaking change Partial Reloads no longer work as documented in Inertia 2.0 - Unlisted breaking change Jan 2, 2025
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

No branches or pull requests

1 participant