I am getting an error of undefined variable $message in my Laravel project. (this is just test code I wrote) I don’t think my logic is correct, it must not be.
This is TestComponent.php
<?php
namespace AppHttpLivewire;
use LivewireComponent;
class TestComponent extends Component
{
public $message = "Hello, World!";
public function mount($message){
$this->message = $message;
}
public function render()
{
return view('livewire.test-component');
}
}
and here is my blade file test-component.blade.php
<div>
@if(isset($message))
{{ $message }}
@else
<p>$message is not set!</p>
@endif
@dump($message)
</div>
and then i just have the component included in my app.blade.php
<livewire:test-component />
I really don’t get why this error is popping up, I was initially trying to pass data from a Filament Resource, and I was getting the same error so I just simplified it. I guess my logic must be wrong.
if i didn’t use the text editor correctly, please bare with me, I am new to this… this is like my second question.
MoodyGirl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.