In a live view I have this snippet:
<div id="chat"><%= live_render(@socket, MyAppWeb.ChatLive.Index, id: "watch-chats", guest: @guest) %></div>
In ChatLive.Index I have this mount function:
@impl true
def mount(%{"guest_id" => guest_id}, _session, socket) do
...
end
def mount(:not_mounted_at_router, session, socket) do
mount(%{"guest_id" => socket.assigns.guest.id}, session, socket)
end
but it gives this error:
key :guest not found in: %{flash: %{}, live_action: nil}
at the line with mount(%{"guest_id" => socket.assigns.guest.id}, session, socket)
.
How can I pass in a parameter such as guest to the live_render
call and pick it up within the mount
function?