hotwired-laravel / turbo-laravel

This package gives you a set of conventions to make the most out of Hotwire in Laravel.
https://turbo-laravel.com
MIT License
791 stars 48 forks source link

Stimulus scrips are loaded twice on second visit #56

Closed ekrist1 closed 2 years ago

ekrist1 commented 2 years ago

I don't know if this is a Turbo or Hotwire issue, or if it somehow is linked to the Laravel Hotwire implementation.

It seems like the Stimulus controllers are loaded twice during the second visit. I have a clean install with the hello_controller. On the first visit, everything is fine. If I visit the same page twice, the hello_controller is initialised twice.

Screenshot 2022-03-29 at 17 30 58 Screenshot 2022-03-29 at 17 30 26
ekrist1 commented 2 years ago

Found the explanation here: https://discuss.hotwired.dev/t/controller-initialized-twice-when-visiting-from-a-turbolinks-page/17

Had a 3rd party library which seemed to had some troubles with the caching, so disabling it with data-turbo-cache="false" works.