What's wrong? I've Laravel 10, Livewire 3.
component:
public function mount()
{
$this->post = \App\Models\Post::with('comments')->find(1);
}
template:
<div>
@foreach($post->comments as $index => $comment)
<div wire:key="comment-{{ $comment->id }}">
<input type="text" wire:model="post.comments.{{ $index }}.text">
<pre>{{ print_r($comment) }}</pre> {{-- <- Works fine --}}
</div>
@endforeach
</div>
I get an js error:
Uncaught TypeError: Cannot read properties of null (reading 'comments')
I have no idea. I need help.