Patrick Quijano
Patrick Quijano

Reputation: 351

Livewire Not Rerendering

I do not know what I am missing but I followed every step but it does not rerender the view.

Here's my livewire component class:

use Livewire\Component;

class HelloWorld extends Component
{
    public $message = 'Hello, world!';

    public function render()
    {
        return view('livewire.hello-world');
    }
}

Here's the livewire view:

<input type="text" wire:model="message">{{ $message }}

When I type in the input box, I see XHR requests being sent but the view does not update. What am I missing here? I have been looking around for answers for few hours already.

Upvotes: 4

Views: 4687

Answers (3)

mohammad
mohammad

Reputation: 1

You need to have a root elememt. note that you can have only one root element.

Upvotes: 0

Your blade view must have only one root element and it should looks like below :

<div>
    <input type="text" wire:model="message">{{ $message }}
</div>

Upvotes: 0

DanielHM
DanielHM

Reputation: 206

From Livewire's docs:

Make sure your Blade view only has ONE root element. Source

Putting it in a div should fix this issue.

Upvotes: 19

Related Questions