Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.x] Add livewire component paths to default refresh paths for livewire stack #1081

Merged
merged 1 commit into from
Jul 11, 2022

Conversation

timacdonald
Copy link
Member

@timacdonald timacdonald commented Jul 2, 2022

This is dependent on merging and tagging of:

so the tests are currently failing, however this has been tested locally.

This PR additionally watches app/Http/Livewire/** in the Livewire stack, as "inline" components contain all their view logic there. When files there change, the browser will perform a full page refresh.

Test script...

composer create-project laravel/laravel:9.x-dev jetstream-test \
  && cd jetstream-test \
  && composer require laravel/jetstream:livewire-refresh-dev \
  && php artisan jetstream:install livewire \
  && sed -i "s/SESSION_DRIVER=database/SESSION_DRIVER=file/" .env \
  && npm install \
  && npm run dev

php artisan serve

php artisan make:livewire Counter --inline

Put the following in your welcome.blade.php

<!DOCTYPE html>
<html>
    <head>
        @vite(['resources/js/app.js', 'resources/css/app.css'])
    </head>
    <body>
        <livewire:counter />
    </body>
</html>

Then put the following in your Livewire component...

<?php

namespace App\Http\Livewire;

use Livewire\Component;

class Counter extends Component
{
    public function render()
    {
        return <<<'blade'
            <div>
                hello world.
            </div>
        blade;
    }
}

You should not be able to edit the Livewire component and see the browser refresh and show the new content.

@timacdonald timacdonald requested a review from jessarcher July 2, 2022 07:48
@timacdonald timacdonald marked this pull request as draft July 3, 2022 02:21
@timacdonald timacdonald marked this pull request as ready for review July 7, 2022 00:51
@taylorotwell taylorotwell merged commit ee23dac into 2.x Jul 11, 2022
@taylorotwell taylorotwell deleted the livewire-refresh branch July 11, 2022 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants