This is an example repository that demonstrates an issue where deadview phx-hook
s don’t run when a liveview is live_render
ed on the page.
This repository uses two hooks, HelloDeadView
and HelloLiveView
. They each write a message to the browser console.
- To repro the issue where a deadview hook is not executed, run
mix phx.server
and open a browser to http://localhost:4000. You’ll only see "Hello live view" in the browser console. - To observe that the deadview hook does run when
live_render
is not called, remove thelive_render
in index.html.heex. The browser console should now show "Hello dead view".
The LiveView 0.18 changelog included the enhancement "Add dead view support for hooks". I’d expect that this support would still work on a hybrid page that embeds a rendered LiveView but is otherwise dead.