RooSoft
Phoenix LiveView 0.18 and live_flash
This live.html.heex file has been generated by mix itself a while ago and hasn’t been touched since, although very useful
<main>
<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>
Now that our app is being upgraded to LiveView 0.18, it gets compilation errors
== Compilation error in file lib/app_web/views/layout_view.ex ==
** (CompileError) lib/app_web/templates/layout/live.html.heex:4: undefined function live_flash/2 (expected AppWeb.LayoutView to define such a function or for it to be imported, but none are available)
I’ve been searching all over to understand what’s going on and can’t find out why… Actually, the only way to fix this for now is to comment them flashes.
Marked As Solved
sabiwara
It has been moved from Phoenix.LiveView.Helpers to Phoenix.Component, as mentioned in the changelog.
Replacing import Phoenix.LiveView.Helpers by import Phoenix.Component should fix it.
Also Liked
knoebber
kartheek
LiveView modules are reorganised in 0.18. live_flash is now inside Phoenix.Component. You have to adjust imports inside view_helpers function in your_project_web.ex file
Those new components live in the
Phoenix.Componentmodule.Phoenix.LiveView.Helpersitself has been soft deprecated and all relevant functionality has been migrated. You mustimport Phoenix.Componentwhere you previously importedPhoenix.LiveView.Helperswhen upgrading. You may also need toimport Phoenix.Componentwhere you also importedPhoenix.LiveViewand some of its functions have been moved toPhoenix.Component.
Additionally, the specialletattribute on function components have been deprecated by a:letusage.
You can read more about it in release notes - phoenix_live_view/CHANGELOG.md at main · phoenixframework/phoenix_live_view · GitHub
RooSoft
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









