I have what I think is a super-simple live component that I’m calling in a straightforward LiveView:
First, the code below works fine, and I see “hi tadasajon” in a red outlined div:
# router.ex
live("/test", TestLive, :index)
# test_live.ex
defmodule MyAppWeb.TestLive do
use MyAppWeb, :live_view
def render(assigns) do
~H"""
<div class="outline-red p-4 m-4">
hi tadasajon
</div>
"""
end
end
Now I want to add a live component, so I have done this:
# router.ex
live("/test", TestLive, :index)
# test_live.ex
defmodule MyAppWeb.TestLive do
use MyAppWeb, :live_view
def render(assigns) do
~H"""
<div class="outline-red p-4 m-4">
hi tadasajon
<.live_component id="unique-id" module={MyAppWeb.TestLiveComponent} />
</div>
"""
end
end
# test_live_component.ex
defmodule MyAppWeb.TestLiveComponent do
use Phoenix.LiveComponent
def render(assigns) do
~H"""
<div> hello again, tadasajon </div>
"""
end
end
The error I am getting is:
** (KeyError) key :__live__ not found in: %{__changed__: nil, id: "unique--id", module: MyAppWeb.TestLiveComponent}