mikebarlow/megaphone

Livewire multiple root error in production

Boomchart opened this issue · 2 comments

I have been getting this error in production but not in localhost.

Livewire: Multiple root elements detected. This is not supported. See docs for more information https://laravel-livewire.com/docs/2.x/troubleshooting#root-element-issues

Hey,
I've just tested a fresh copy of Megaphone on a fresh Laravel installation and I've not received the error. Given the nature of the error you've received and the problem/solutions mentioned on that Livewire docs page, I don't think the error lies with Megaphone.

Have you made any modifications to the published megaphone views at all?
Alternatively, are you trying to add Megaphone into another Livewire component? If so the problem could be with that component and not Megaphone itself.

That link you posted is pretty clear with the solution to the fix so it would be worth looking in the root megaphone view (resources/views/vendor/megaphone/megaphone.blade.php) in case you made any changes to that and the root view for any other Livewire Components you have created.

Even after deleting the published assets error still persisted, the solution was adding <div><livewire:megaphone></livewire:megaphone></div> not just <livewire:megaphone></livewire:megaphone>