Ok, a few things:
- public properties on the Component class are available directly in the component view, so you don't need to pass data to the view
- when you use the
wire:modeldirective without thelivemodifier, the change does not get sent immediately to the backend. - you do not need the
updatedSelectedValuemethod since the public property is reactive already, and you were only updating the already updated public property
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class SelectTest extends Component
{
public $selectedValue = 'option1';
public function render()
{
return view('livewire.select-test');
}
}
<div>
<label for="selectBox">Select Box:</label>
<select id="selectBox" wire:model.live="selectedValue">
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
</select>
<p>Selected Value: {{ $selectedValue }}</p>
</div>
Now, everything will be live and updating as expected.