InvalidArgumentException View [layouts.app] not found. Larave-8 LliveWire-2

Viewed 1429

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

2 Answers

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

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

Related