'InvalidArgumentException View [layouts.app] not found. Larave-8 LliveWire-2
When I change app.blade.php
to base.blade.php
I am having the following error.
InvalidArgumentException View [layouts.app] not found. (View: D:\Code\my-app\vendor\livewire\livewire\src\Macros\livewire-view-component.blade.php)
layouts.app was not found.
Did you mean layouts\base?
Otherwise, it works great.
-Here is my code.
resources\views\layouts\base.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
@livewireStyles
</head>
<body>
@livewire('auth.register')
@livewireScripts
</body>
</html>
resources\views\livewire\auth\register.blade.php
<div>
Registration Form
</div>
web.php
<?php
use App\Http\Livewire\Auth\Register;
use Illuminate\Support\Facades\Route;
Route::get('/register', Register::class);
app\Http\Livewire\Auth\Register.php
<?php
namespace App\Http\Livewire\Auth;
use Livewire\Component;
class Register extends Component
{
public function render()
{
return view('livewire.auth.register');
}
}
Note: app.blade.php is still works
Solution 1:[1]
You have to search for any that refers to the last app.blade.php source. In some cases, are blades that extends from the main, so maybe that blades have the directives @extends('layout.app') and need be well referenced
Solution 2:[2]
If you are using an "out of the box" installation of Livewire to create a full-page component, then the location of the root blade file is hardcoded to resources/views/layouts/app.blade.php It cannot be changed in the basic "zero-configuration" Livewire installation and is the reason why searching for "layout" finds no mention.
If you want to change Livewire's configuration, you have to publish the config file.
php artisan livewire:publish --config
This gives you a config/livewire.php file which is where you will find the default layout file.
'layout' => 'layouts.app',
which you will need to change to
'layout' => 'layouts.base',
Further reading
https://laravel-livewire.com/docs/2.x/rendering-components#page-components
https://laravel-livewire.com/docs/2.x/installation#publishing-config
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Prospero |
Solution 2 | MortimerCat |