I'm trying to add a new Livewire component to Laravel 8 Jetstream but looks I'm doing something wrong and getting the following error.

Error:

RootTagMissingFromViewException

Livewire\Exceptions\RootTagMissingFromViewException
Livewire encountered a missing root tag when trying to render a component. When rendering a Blade view, make sure it contains a root HTML tag

Route:

// web.php
Route::middleware('auth')->group(function() {
    Route::get('/newEmployee', NewEmployee::class);
});

Controller:


// app/Http/Livewire/NewEmployee.php

namespace App\Http\Livewire;

use Livewire\Component;

class NewEmployee extends Component
{
    public function render()
    {
        return view('livewire.new-employee')->layout('layouts.app')->name('NewEmployee');
    }
}

View:

<!-- resources/views/livewire/new-employee.blade.php  -->
<div>
    <div class="max-w-7xl mx-auto py-10 sm:px-6 lg:px-8">
            <h1> New Wmployee </h1>
    </div>
</div>
2

There are 2 answers

2
mahabubul On BEST ANSWER

Won't (name) the method. Please define:

return view('livewire.new-employee')->layout('layouts.app');
0
Vijay On

You need add any HTML Tags in your livewire BLADE file. LiveWire need HTML TAG in BLADE file. So add simple TEST PAGE in LIVEWIRE BLADE. Issue should resolved.