Packages
Phoenix.React is use for renders React component as Phoenix Component in heex template. Support render_to_string and render_to_static_markup and cache render result. Only render to string support hyrate react component with phx-hook.
Current section
Files
Jump to
Current section
Files
lib/phoenix/react/helper.ex
defmodule Phoenix.React.Helper do
@moduledoc false
require Logger
def react_component(file, props, _opts \\ []) do
{:ok, html} = Phoenix.React.render_to_string(file, props)
%Phoenix.LiveView.Rendered{
static: [html],
dynamic: fn _assigns -> [] end,
fingerprint: :erlang.phash2("components/markdown.js"),
root: nil,
caller: :not_available
}
end
defmacro __using__(_) do
quote do
import Phoenix.React.Helper
end
end
end