Phoenix LiveView mount does not get called

I have tried creating a fresh project using LiveView. I am following this tutorial : I have followed the installation instruction manual and created a basic controller for my view, that contains a live_render tag, referencing a LiveView controller.

Template :

<%= live_render(@conn, TodoistHelperWeb.AppController) %>

Normal controller :

defmodule TodoistHelperWeb.PageController do                                                                                                                                                                                                                                
  use TodoistHelperWeb, :controller                                                                                                                                                                                                                                         
  def index(conn, _params) do                                                                                                                                                                                                                                               
    render(conn, "index.html")                                                                                                                                                                                                                                              

LiveView controller :

defmodule TodoistHelperWeb.AppController do                                                                                                                                                                                                                                 
  use Phoenix.LiveView                                                                                                                                                                                                                                                      
  def mount(_session, socket) do                                                                                                                                                                                                                                            
    {:ok, assign(socket, projects: ["project1"])}                                                                                                                                                                                                                                  
  def render(assigns) do                                                                                                                                                                                                                                                    
      TodoistHelperWeb.AppView.render("projects.html", assigns)                                                                                                                                                                                                             

LiveView template :

<%= for project <- @projects do %>                                                                                                                                                                                                                                          
<div><%= project %></div>                                                                                                                                                                                                                                                   
<% end %>

The project compiles correctly, everything seems to work, but the @projects variable cannot be found in the liveview template! If I replace it with a static list, the page is displayed without any errors. Using print statements, I was able to determine that render is properly called, however mount is not.

What did I miss? Did I mess up one of the installation steps?

It should be mount/3:

@impl true
def mount(_params, _session, socket) do
  {:ok, assign(socket, projects: ["project1"])}

If you put @impl true whenever you are implementing a callback, Elixir will let you know if you got the wrong name or the wrong number of arguments. :slight_smile:


Oh god that was pretty dump -_-… Thanks!