Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve RootTagMissingFromViewException error while adding new Livewire component in Laravel 8 with Jetstream

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>
like image 861
Jeff Avatar asked Oct 27 '25 08:10

Jeff


1 Answers

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

return view('livewire.new-employee')->layout('layouts.app');
like image 97
mahabubul Avatar answered Oct 29 '25 22:10

mahabubul