Lazy load on custom page

I have created a custom page and copied in my old livewire component. As involves an API call which is a tad slow. Is there a way to lazy load the page? Show some sort of loading width on the page whilst its grabbing the data. At the moment it takes 3-5 seconds to load the page.
12 Replies
krekas
krekasβ€’12mo ago
custom page is a livewire component. check the livewire docs for lazy loading
David | Fortune Validator
David | Fortune ValidatorOPβ€’12mo ago
I have and I have this working just fine on standard livewire/laravel. But to call a livewire component as lazy you do so when calling the livewire compoenent itself or on the route. Neither which I have access to within the Custom Page file itself. Unless I am missing something silly
awcodes
awcodesβ€’12mo ago
Laravel
Lazy Loading | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
David | Fortune Validator
David | Fortune ValidatorOPβ€’12mo ago
I did try this actaully. It has a weird behavior whereby it will show me the page I want BUT it takes it out of the panels wrapper and its onto my non filament part of the site. I.e I see my non filament nav bar etc and no filament sidebar/nav at all
David | Fortune Validator
David | Fortune ValidatorOPβ€’12mo ago
No description
No description
David | Fortune Validator
David | Fortune ValidatorOPβ€’12mo ago
first screenshot being the navbar from my NON filament part of the site. and the second image being where I click on to view the custom page. If I take off the #[Lazy] it will laod within the panel wrapper no problem but not with lazy benefits so it takes 5 or so seconds to load
awcodes
awcodesβ€’12mo ago
only thing i can think to do then is too make an 'internal' livewire component for the page to use, then you can do lazy in the view like you are used to. and just pass the record to the internal LW component if there is a record
David | Fortune Validator
David | Fortune ValidatorOPβ€’12mo ago
okay okay, I think I follow you. I'll give that a whirl an report back thank you that worked a treat. Page loads fast and the data come a few seconds later. Only thing I need to figure out is all the tailwind styles have not been applied
awcodes
awcodesβ€’12mo ago
you'll need a custom theme so it can scan your views directory for classes
David | Fortune Validator
David | Fortune ValidatorOPβ€’12mo ago
I do have a custom theme already ( albeit only freshtly created it last night ) so I may not have configured that correctly yet
awcodes
awcodesβ€’12mo ago
or you need to run a build at least it's working. πŸ™‚
David | Fortune Validator
David | Fortune ValidatorOPβ€’12mo ago
and fixed thank you so much
Want results from more Discord servers?
Add your server