Render returns empty array

I’m trying to get some data but in some cases, query return an empty array on render method. When trying to pass empty array to component’s view I’ve got an undefined offset = 1

Ask for code if neccesary

Offset comes on this function:

class AddAttributesToRootTagOfHtml {

public function __invoke($dom, $data) {

    $attributesFormattedForHtmlElement = collect($data)
        ->mapWithKeys(function ($value, $key) {
            return ["wire:{$key}" => $this->escapeStringForHtml($value)];
        })->map(function ($value, $key) {
            return sprintf('%s="%s"', $key, $value);
        })->implode(' ');
    preg_match('/<([a-zA-Z0-9\-]*)/', $dom, $matches, PREG_OFFSET_CAPTURE);
    $tagName = $matches[1][0]; (HERE IS WHERE STOP)

Solved by myself.

LiveWire component view needs a html element before print any returned value from component controller. E.g:

<div> //missed on my code
    @foreach($users as $user)
        {{$user->id}}
    @endforeach
</div>