Livewire Error: public property [message] must be of type: [numeric, string, array, null, or boolean]

  laravel, laravel-livewire

I am getting this issue, and I don’t understand what I am doing wrong as I did this same exact approach for another component on this site, and works perfectly….


public $messages;

public function mount($messages)
        $this->messages = $messages;


<div class="flex flex-col">
        @foreach ($messages as $message)

Everything works and it outputs all the messages correctly.

When I try and pass in a livewire component into the for each, it gives that error.

@foreach ($messages as $message)
       @livewire('', ['message'=>$message], key('show-message-'.$message->id))

// ShowMessage.php
public $user;
    public $message;
    public $user_id;
    public $content;

    public function mount($message)
        $this->message = $message;

Honestly am lost on what I am doing wrong, as I copied the exact same code and changed the variables that I used before. It works right now on the site when I do nested components.

<div class="flex flex-col space-y-4 py-4 overflow-y-auto">
     @foreach ($chats as $chat)
          @livewire('', ['chat'=>$chat], key('chat-'.$chat->id))

I redid this component already twice, and can’t find any syntax issues or spelling errors. =/

Source: Laravel

Leave a Reply