RooSoft

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

sabiwara

Elixir Core Team

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.

12
Post #2

Also Liked

kartheek

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.Component module. Phoenix.LiveView.Helpers itself has been soft deprecated and all relevant functionality has been migrated. You must import Phoenix.Component where you previously imported Phoenix.LiveView.Helpers when upgrading. You may also need to import Phoenix.Component where you also imported Phoenix.LiveView and some of its functions have been moved to Phoenix.Component.
Additionally, the special let attribute on function components have been deprecated by a :let usage.

You can read more about it in release notes - phoenix_live_view/CHANGELOG.md at main · phoenixframework/phoenix_live_view · GitHub

RooSoft

RooSoft

Working perfectly, thanks guys!

Love this community…

Where Next?

Popular in Questions Top

RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

We're in Beta

About us Mission Statement