Search code examples
laravellaravel-livewire

Call to a member function getBag() on array error after upgrading to Laravel10 and Livewire 3


After upgrading my app to Laravel 10 and Livewire 3, I get this error on a page:

Call to a member function getBag() on array

The code that gives this error is just an @error directive on my blade file:

@error('firstName')
    <p class="mt-2 text-red-500 italic text-xs">
        {{ __('Please enter your first name') }}
    </p>
@enderror

where firstName is a public property on my component, with validation rules present.

public $firstName;
...
$rules =  [
    'firstName' => 'required',
    ...

It worked before the upgrade, and it worked after Laravel10 upgrade, so I think it is coming from Livewire 3.

Thank you for any feedback!


Solution

  • I had a public property $errors = [] declared in my component by mistake. That was causing that strange error. After I deleted that property, it all works perfectly fine.