I am migrating my website’s index page to a LiveView. After setting the LiveView up, there are always empty info
and error
flash containers at the beginning of the page.
They reappear even after refreshing the browser. Clicking on the flashes does not close them.
# live.html.heex
<main class="container">
<p class="alert alert-info" role="alert"
phx-click="lv:clear-flash"
phx-value-key="info"><%= live_flash(@flash, :info) %></p>
<p class="alert alert-danger" role="alert"
phx-click="lv:clear-flash"
phx-value-key="error"><%= live_flash(@flash, :error) %></p>
<%= @inner_content %>
</main>
# router.ex
...
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, {MyAppWeb.LayoutView, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers
plug :fetch_current_user
end
...
scope "/", MyAppWeb do
pipe_through :browser
live "/", ListsLive
end
...