Simple Phoenix LiveView App: Upgrade to LiveView 0.5.1

This upgrades our app from Phoenix LiveView from 0.4.0 to 0.5.1, and includes a friendly reminder:

When you follow a tutorial, it's much easier for you if you use the same library versions as in the tutorial to go through the tutorial! Afterwards you'll have more understanding of how everything works and upgrading will be much less painful. In the case of this series, I'll be covering upgrades as we go. In fact, v0.6.0 has just been released and once its docs have caught up with it, we'll be upgrading the app again.

Upgrading to LiveView 0.5.1

First we'll update the version number in mix.exs:

defp deps do
    # ...
    {:phoenix_live_view, "~> 0.5.1"}

Then we'll pull in the new version:

mix deps.get

Running the app now throws an error:

(CompileError) lib/reactor_web/views/layout_view.ex:2: cannot import Phoenix.LiveView.live_render/2 because it is undefined or private

The reason for this error is that live_render/2, along with several other functions were moved into a helpers module in LiveView version 0.5.

Updating web.ex

Fortunately, the fix is simple. Just change this portion of reactor_web.ex from:

import Phoenix.LiveView,
  only: [
    live_render: 2,
    live_render: 3,
    live_link: 1,
    live_link: 2,
    live_component: 2,
    live_component: 3,
    live_component: 4


import Phoenix.LiveView.Helpers

And everything is up and running again.

Back to index

No Comments