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

[2.x] Prefetch doesn't load deferred props #2108

Open
javieralarcn10 opened this issue Nov 26, 2024 · 3 comments
Open

[2.x] Prefetch doesn't load deferred props #2108

javieralarcn10 opened this issue Nov 26, 2024 · 3 comments
Labels
react Related to the react adapter

Comments

@javieralarcn10
Copy link

javieralarcn10 commented Nov 26, 2024

Version:

  • @inertiajs/react version: 2.0.0-beta.2

Describe the problem:

When I prefetch a <Link prefetch/> it only loads props that don't have the Inertia::defer method.

Steps to reproduce:

Controller:
return inertia('Dashboard/Products/Inventory', [ 'shop' => $shop, 'inventory' => Inertia::defer(fn() => $shop->inventory), ]);

Frontened:
<Link prefetch href={route("inventory")} className="flex gap-2 items-center"> <span className="font-medium text-white">Inventory</span> </Link>

@javieralarcn10 javieralarcn10 added the react Related to the react adapter label Nov 26, 2024
@mreduar
Copy link

mreduar commented Dec 11, 2024

That is not the objective of defer? That they only load when you enter the page?

@RobertBoes
Copy link
Contributor

I agree, it shouldn't prefetch deferred props, as that may take a long time while in the meantime the user could navigate, which would then cause the page to load very slowly

@mathewparet
Copy link

It should load deferred props too, but as a second request (like how prefetch works normally).

For example, I assume that if a user is hovering over Paginator links chances are they want to click the next page or the page number over which they are hovering.

This works fine except if the page has deferred components, it looks like prefetch does prefetch the initial data, but doesn't seem to go back for the deferred data. The problem with this is now that if a user clicks on a page then nothing shows at all.

Oh! BTW, this issue exists in Vue also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
react Related to the react adapter
Projects
None yet
Development

No branches or pull requests

4 participants