I'm experiencing an issue with Laravel Livewire. I keep getting the error "Unable to find component: [navigation-menu]" when navigating to my dashboard. This is puzzling because the component does actually exist.
@livewire('navigation-menu')
I've run the commands php artisan view:clear and php artisan cache:clear to clear any cached versions, but to no avail.
The error seems to highlight this line:
`
$__html = app('livewire')->mount($__name, $__params, 'some_string_here', $__slots ?? [], get_defined_vars());
`
If anyone has encountered a similar issue or has any ideas on what I could try next, your input would be greatly appreciated.
If you've changed the namespace from the default one, if you add it to a service provider (custom or not) within boot then it will register the component.
public function boot(): void
{
Livewire::component('navigation-menu', NavigationMenu::class);
}
...and don't forget to import Livewire and NavigationMenu too
@jaseofspades88 This is exactly what I needed. However, is there any way to configure Livewire to automatically discover components? I broke my application into modules (app/Modules) and for each module, I recreated a service provider (e.g. app/Modules/Registration/RegistrationServiceProvider.php). In the boot method of that file, I call:
There is a way yes, @shomari - use the default structure that Livewire expects, otherwise it can't 'automatically' resolve the component from anywhere. This is why you need to register it accordingly.