inertia-laravel icon indicating copy to clipboard operation
inertia-laravel copied to clipboard

Lazy loading not working with nested response

Open andelwebsolutions opened this issue 3 years ago • 0 comments

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.

andelwebsolutions avatar Feb 11 '22 15:02 andelwebsolutions