How to Create Nested LiveView Components: Difference between revisions
From ElixirBlocks
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 12: | Line 12: | ||
~H""" | ~H""" | ||
Hello World! YAY | Hello World! YAY | ||
<MyComponent.greet name="Jane" /> | |||
""" | """ | ||
end | end |
Latest revision as of 12:25, 6 April 2023
This example demonstrates a nested LiveView component.
defmodule AppxWeb.SandboxLive do use AppxWeb, :live_view import MyComponent def mount(_params, _session, socket) do {:ok, socket} end def render(assigns) do ~H""" Hello World! YAY <MyComponent.greet name="Jane" /> """ end end
defmodule MyComponent do use Phoenix.Component def greet(assigns) do ~H""" <p>Hello, <%= @name %>!</p> """ end end