inertia-laravel
inertia-laravel copied to clipboard
Lazy loading not working with nested response
Lazy loading the revenue data doesn't work when it's nested. See example below.
See DashboardController.
return Inertia::render('Dashboard', [
'charts' => Inertia::lazy(fn () => [
'revenue' => Inertia::lazy(fn () => (new RevenueChart(Carbon::now()->subYear(1), Carbon::now()))->getData())
])
]);
And in Dashboard.vue
onMounted(() => {
Inertia.replace(route('dashboard'), {
preserveState: true,
preserveScroll: true,
replace: true,
only: ['charts.revenue']
})
})
The revenue chart data is not being loaded lazily but on page request instead.